“No tests found” for instrumentation tests for Lollipop and above

烈酒焚心 提交于 2019-12-21 07:41:06

问题


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).


回答1:


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'



来源:https://stackoverflow.com/questions/34042730/no-tests-found-for-instrumentation-tests-for-lollipop-and-above

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!