Search code examples
androidjunit4android-testingjunit3

JUnit 4 with ActivityInstrumentationTestCase2


Is possible I use JUnit 4 with my class extend ActivityInstrumentationTestCase2?

I am getting the following warn:

@Test inside class extending JUnit3 TestCase

My class

public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
}

Solution

  • Is possible I use JUnit 4 with my class extend ActivityInstrumentationTestCase2?

    Yes, though you have to follow the documented recipe (see the ActivityInstrumentationTestCase2 instructions part-way down the page).

    This sample project contains an ActivityInstrumentationTestCase2 that follows the recipe.

    I am getting the following warn

    Yes, that's an IDEA warning that should be fixed in an upcoming release of Android Studio.