I’m trying to use
Android Support Test Library (previously android-test-kit) and create tests for one of my projects. It contains some ‘functional’ code along with UI code in single project.
My intention is to use JUnit4 and not mix with JUnit3, so I use AndroidJUnitRunner. There’s number of test classes created for the ‘functional’ code which follow JUnit4 and work fine.
Recently I’ve started to implement tests for UI components. Referring documentation receipt number of tests have been implemented. These activity tests follow JUnit4 style and extend
ActivityInstrumentationTestCase2 based on above doc.
The problem that I’m facing now: it’s not possible to execute all tests at once. If I try to run package / all tests (Activity and ‘functional’ are presented in the same project) from IntelliJ Idea – only pure JUnit4 tests get executed. I suspect that the problem is in
ActivityInstrumentationTestCase2 which extends
TestCase and is not pure JUnit4 test class.
Is it possible somehow to get rid of ActivityInstrumentationTestCase2 in Activity tests using Android Support Test Library (android-test-kit) and have all test running? Or my assumption about the issues rootcause (about
TestCase) is wrong?
Finally found only possible solution: copy
ActivityInstrumentationTestCase2 into my project from AOSP source. After that, remove inheritance from
TestCase. Same way it’s done in this project (AndroidJunit4). There’s actually no need for
TestCase and these changes and documentation receipt are enough to have activity tests to be JUnit4 and avoid mixing issues.
Answered By – sandrstar