Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No tests found" for instrumentation tests for Lollipop and above

My instrumentation based (espresso) tests don't run on Lollipop+ devices and emulators. They correctly run on any other platform. I have the same symptoms as the guy in this thread - https://groups.google.com/forum/?fromgroups#!topic/adt-dev/QW5SuzQizNk

  • My tests are in src/androidTest/java/
  • I've set testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
  • The test classes are @RunWith(AndroidJUnit4.class)
  • Individual tests are annotated with @Test

I can execute a ./gradlew connectedCheck and the tests run well on a device with KitKat, but when I try to run the same tests the same way on a device with Lollipop I get...

15:02:15.784 [WARN] [org.gradle.api.Task] Tests on XT1095 - 5.1 failed: Instrumentation run failed due to 'java.lang.NoClassDefFoundError'

15:02:16.011 [WARN] [org.gradle.api.Task] com.android.builder.testing.ConnectedDevice > No tests found.[XT1095 - 5.1] FAILED

15:02:16.011 [WARN] [org.gradle.api.Task] 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).

like image 534
Mariusz Avatar asked Dec 02 '15 12:12

Mariusz


1 Answers

Finally it started working. I followed this answer: https://groups.google.com/d/msg/adt-dev/QW5SuzQizNk/mWdaEuuCCQAJ which links to: https://github.com/google/dagger/issues/271

Basically this was the problem:

I incorrectly used compile 'com.google.dagger:dagger-compiler:2.0.2'

instead of correct apt 'com.google.dagger:dagger-compiler:2.0.2'

like image 68
Mariusz Avatar answered Nov 15 '22 17:11

Mariusz