Search code examples
androidgradleandroid-testingandroid-instrumentation

"No tests found" error in a module that has no tests


I got a "No tests found" error for a specific module that has no instrumented tests (only JUnit tests) when running gradlew connectedAndroidTest in the pipeline. It's a bad thing because the app has other modules that have instrumented tests that don't run because the Gradle task fails.

Task :actions:connectedDebugAndroidTest
Starting 0 tests on android_emulator(AVD) - 8.1.0
com.android.build.gradle.internal.testing.ConnectedDevice > No tests found.android_emulator(AVD) - 8.1.0 FAILED
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
Task :actions:connectedDebugAndroidTest FAILED

I've tried removing androidTest dependencies and testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" but the problem is still happening.


Solution

  • Deleting androidTest directory solved the problem (the folder had no classes but had a .gitkeep file).

    Apparently, it fails when the folder exists but has no tests in it.