0

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> {
}
Abdelrahman Elkady
  • 2,518
  • 2
  • 21
  • 30
Douglas Mesquita
  • 860
  • 1
  • 13
  • 30

2 Answers2

4

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

Nope. Android JUnit is JUnit3. Tests are method whose name begins with "test"

G. Blake Meike
  • 6,615
  • 3
  • 24
  • 40
  • 1
    `AndroidJUnitRunner` offers support for JUnit4, with specific instructions for getting `ActivityInstrumentationTestCase2` working. It's a trifle clunky and triggers the IDEA warning mentioned in the question, but it works. – CommonsWare Jan 21 '15 at 15:55
  • 2
    I'll be darned! Voting myself down. – G. Blake Meike Jan 22 '15 at 00:30