The question is, are you testing unit testing or integration testing?
If you are unit testing, I would suggest using mocks in the old-fashioned way, using setter and trying to test Java code without the involved attachment infrastructure. This will test your class in isolation and cost a lot more.
What I mean:
public class Test{ ClassInTest inTest; MyInterface myInterface; @Before public void setup(){ inTest = new ClassInTest();
Of course, testing the activity of Android (and other Android extensions) is difficult due to the exception of throws and final classes / methods. This is where Robolectric comes in handy (and highly recommended) for creating / shadowing the Android API.
If you are integration testing, you may need a different approach. Personally, I will try not to scoff at integration tests, as I try to test the application in the way it will work during the production process. But, if you really want to taunt, you can use a similar approach to unit testing and introduce a layout after you step on the generated activity class. It is worth noting that you can perform integration tests directly on the hardware using frameworks such as Robotium .
More about your question, I donβt know about any AndroidAnnotations tools specifically for injecting Mocks or injecting Mocks into a nested application dependency tree.
John Ericksen
source share