I开发者_开发百科 am fairly new to unit testing, in android specifically. I have written an application with numerous activities. However, some of these activities rely on certain objects for them to populate the activity's views. I guess my question is: Is there a way I can mock up the objects within the Activity and make the activity use that created mock object from my Junit tests? Thanks in advance, I cant find the solution for this anywhere?
You can also take a look at AndroidMock:
http://code.google.com/p/android-mock/wiki/UsingAndroidMock
It is a Mock Objects framework for Android build on top of EasyMock.
If you refere to the developer guide under Create a Local Unit Test Class heading, you will find the answer to your question. Also refer to the "Mock Android Dependecies" sub heading on the same page.
精彩评论