Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The question is, are you unit testing or integration testing?</p> <p>If you are unit testing, I would suggest using mocks the old fashioned way, by using a setter and trying to test the Java code without the dependency injection framework involved. This will test your class in isolation and sidesteps a lot of complexity.</p> <p>What I mean:</p> <pre><code>public class Test{ ClassInTest inTest; MyInterface myInterface; @Before public void setup(){ inTest = new ClassInTest(); //or your favorite mocking frameowrk myInterface = EasyMock.createMock(MyInterface.class); inTest.setMyInterface(myInterface); } @Test public void testMethod(){ //...mocking test code } } </code></pre> <p>Of course, testing Android Activities (and other extensions of Android) is difficult because of the exception throwing stubs and final classes/methods. This is where <a href="https://github.com/robolectric/robolectric">Robolectric</a> comes in handy (and highly recommended) for instantiating/shadowing the Android API.</p> <p>If you are integration testing you may want to take another approach. Personally, I would try not to mock during integration tests as I try to test the application as it would run in production. But, if you really want to mock, you could use a similar approach to unit testing and introduce a mock after you stand up your generated Activity class. Worth noting, you can perform integration tests directly on the hardware using frameworks like <a href="http://code.google.com/p/robotium/">Robotium</a>.</p> <p>More to your question, I am not aware of any facilities of AndroidAnnotations specifically for injecting Mocks or introducing Mocks into the injected dependency tree of an application.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload