【问题标题】:instrumentation tests failing to run via Gradle task but runs from Android Studio仪器测试无法通过 Gradle 任务运行,但从 Android Studio 运行
【发布时间】:2018-04-08 15:22:51
【问题描述】:

我在 Android 的一个库项目中有几个 Android 测试。当我从 Android Studio 运行测试时,它会运行,但是当我将它作为 Gradle 任务运行时,由于运行时 logcat 中出现以下异常,它无法运行。

Caused by: java.lang.ClassNotFoundException: 
Didn't find class "javax.swing.tree.DefaultTreeCellRenderer"
on path: DexPathList[[zip file "/system/framework/android.test.mock.jar", 
zip file "/system/framework/android.test.runner.jar"

我收到以下错误。

在 Nexus 5X - 8.1.0 上的测试失败:检测运行因“进程崩溃”而失败。

com.android.builder.testing.ConnectedDevice > No tests found.[Nexus 5X - 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).
:app:connectedDebugAndroidTest FAILED

【问题讨论】:

    标签: android android-gradle-plugin android-espresso android-instrumentation


    【解决方案1】:

    我也遇到过这种情况,尤其是在 kotlin 项目中。

    我的解决方法是右键单击左侧项目窗口中的包(在 androidTests 中)并选择“创建所有测试...”它会创建一个应该可以工作的运行配置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-22
      • 1970-01-01
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多