We have a library project and multiple applications depends on it. And the unit tests are in the library project. We're able to run the tests from dependent projects in Android Studio, but
./gradlew :[DependentProject]:connectedAndroidTest
always returns "No test found, nothing to do”.
Through observation, I found in Android Studio, seems that it only executes gradle tasks:
:[DependentProject]:assembleDebug, :[DependentProject]assembleDebugTest
then uses adb to install the target and test apk, and adb shell am instruments to run the tests.
Since connectedAndroidTest depends on these two tasks, I install the target and test apks it produced, and manually invoked instrument command, tests got started.
adb shell am instrument -w com.package.test/android.test.InstrumentationTestRunner
Then the question comes, where does connectedAndroidTest look for tests, and why it cannot find the tests while adb instrument can? How to resolve this issue?
I have the same issue and I solve it by add a method starting with "test"
@Test
public void testWTF() throws Exception {
assertTrue(true);
}
And all other method with @Test
annotation work too !
Amazing no ? I found the answer here : No tests found with test runner 'JUnit 4'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With