This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Running tests | |
Test running started | |
Test running failed: Unable to find instrumentation info for: ComponentInfo{pacakge.name/android.test.InstrumentationTestRunner} | |
Empty test suite. |
like a billion times!
These are the things I have learnt:
- Android/Studio use JUnit 3 so the constructor for your test suite MUST NOT have any parameters (aka don't let Studio create a constructor for you because it will add a parameter and JUnit will not be able to find your test suite):
- Your test needs to be in:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersyourModuleDir/src/instrumentTest/java/ - The package of your test needs to be different from the package of the class you want to test, i.e: if the package for your activity is This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
com.mypacakge.tortoise
then the test should be inThis file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characterscom.mypacakge.tortoise.test - Don't bother trying to run it from the IDE (don't believe this)
- Start your emulator
- Go to <yourProjectDir> (or where your gradlew is)
- Run
./gradlew connectedInstrumentTest
- The results can be found at: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
yourProjectDir/yourModuleDir/build/reports/instrumentTests/connected/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestMainActivity extends ActivityInstrumentationTestCase2<MainActivity> { | |
public TestMainActivity() { | |
super(MainActivity.class); | |
} | |
} |