我在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
答案 0 :(得分:1)
我也遇到过这种情况,特别是对于kotlin项目。
我的解决方法是右键单击左侧项目窗口中的包(在androidTests中)并选择“Create All Tests ...”它会创建一个应该有效的运行配置。