lundi 3 juillet 2017

Android unit testing, says I have no tests inside my class, although I have 1

This is how my ApplicationTest class looks like:

  /**
 * <a href="http://ift.tt/1q3zyPo">Testing 
Fundamentals</a>
 */
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ApplicationTest {
@Rule
public ActivityTestRule mActivityRule =
        new ActivityTestRule(VMBaseActivity.class,
                false /* Initial touch mode */, false /*  launch activity */) {

            @Override
            protected void afterActivityLaunched() {
                // Enable JavaScript.
                Log.i("","activity has been started");
            }
        };

@Test
public void enterPin() {
    // Type text and then press the button.
    onView(withId(R.id.button0)).perform(click());
    onView(withId(R.id.button0)).perform(click());
    onView(withId(R.id.button0)).perform(click());
    onView(withId(R.id.button0)).perform(click());
}
}

I have this in my build.gradle

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

But when I run I get this error:

 Client not ready yet..
 Started running tests

 junit.framework.AssertionFailedError: No tests found in com.vidyo.vidyomod.ApplicationTest
 at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
 at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
 at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
 at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1893)

 Tests ran to completion.

Why doesn't the app find my tests?

Aucun commentaire:

Enregistrer un commentaire