I added the following dependencies to my android project:
// Unit testing dependencies
androidTestCompile 'junit:junit:4.12'
// Set this dependency if you want to use Mockito
androidTestCompile 'org.mockito:mockito-core:1.10.19'
And create a test using junit4 api (an example, Adder is a simple class that sums ints):
@RunWith(MockitoJUnitRunner.class)
public class AdderTest {
@Test
public void testValidAdd() {
Adder adder = new Adder();
assertEquals(adder.add(1,1), 2);
}
}
When I try to run the test, I get:
Running tests Test running started junit.framework.AssertionFailedError: No tests found in com.test.myapp.AdderTest at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701) Finish
I read here and here, but nothing helps.
Does anyone see what I'm doing wrong / have any input?