2

connectedDebugAndroidTest失败了

com.android.builder.testing.ConnectedDevice > 未找到测试。[SM-A310F - 7.0] 失败

未找到任何测试。这通常意味着您的测试类不是您的测试运行程序所期望的形式(例如,不要从 TestCase 继承或缺少 @Test 注释)。

这里的问题是我

  1. 在有两个子项目的父项目上执行任务:lib:mobile并且
  2. 使用过滤器(注释)运行仪器测试。

当我在父项目上运行时,子项目一个接一个地被测试。过滤器确实找到要运行的测试,:lib但没有满足过滤器的测试:mobile。这对我来说完全没问题,但是测试和 CI 失败了。

如果没有找到测试,我如何指示测试不失败(特别是在找到测试的情况下但不是在每个子项目中)

我当前的 gradle 调用是这样的:

gradlew.bat --continue connectedDebugAndroidTest
-P android.testInstrumentationRunnerArguments.annotation=android.support.test.filters.FlakyTest

实际上,我使用了自定义注释,但它的用途与@FlakyTest我刚刚测试的目的相同,以排除自定义注释的问题。

从同一仪器日志中摘录的相关摘录是:

处理第一个子项目的部分:

I/RemoteAndroidTest: Running am instrument -w -r   -e annotation android.support.test.filters.FlakyTest com.example.lib.test/android.support.test.runner.AndroidJUnitRunner on SM-A310F - 7.0
V/ddms: execute: running am instrument -w -r   -e annotation android.support.test.filters.FlakyTest com.example.lib.test/android.support.test.runner.AndroidJUnitRunner
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: numtests=1
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: stream=
V/InstrumentationResultParser: com.example.lib.activities.MainActivityTest:
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: test=testOnCreate
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: class=com.example.lib.activities.MainActivityTest
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: current=1
1 tests on SM-A310F - 7.0
V/InstrumentationResultParser: INSTRUMENTATION_STATUS_CODE: 1
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: numtests=1
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: stream=.
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: test=testOnCreate
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: class=com.example.lib.activities.MainActivityTest
V/InstrumentationResultParser: INSTRUMENTATION_STATUS: current=1
V/InstrumentationResultParser: INSTRUMENTATION_STATUS_CODE: 0
V/InstrumentationResultParser: INSTRUMENTATION_RESULT: stream=
V/InstrumentationResultParser: 
V/InstrumentationResultParser: Time: 1,362
V/InstrumentationResultParser: 
V/InstrumentationResultParser: OK (1 test)
V/InstrumentationResultParser: 
V/InstrumentationResultParser: INSTRUMENTATION_CODE: -1
V/InstrumentationResultParser: 
I/XmlResultReporter: XML test result file generated at TEST-SM-A310F - 7.0-lib.xml. Total tests 1, passed 1, 
V/ddms: execute 'am instrument -w -r   -e annotation android.support.test.filters.FlakyTest com.example.lib.test/android.support.test.runner.AndroidJUnitRunner' on '31006b2f91c74311' : EOF hit. Read: -1
V/ddms: execute: returning
V/ddms: execute: running pm uninstall com.example.lib.test
V/ddms: execute 'pm uninstall com.example.lib.test' on '31006b2f91c74311' : EOF hit. Read: -1
V/ddms: execute: returning

....

处理第一个子项目的部分:

....
I/RemoteAndroidTest: Running am instrument -w -r   -e annotation android.support.test.filters.FlakyTest com.example.mobile.test/android.support.test.runner.AndroidJUnitRunner on SM-A310F - 7.0
V/ddms: execute: running am instrument -w -r   -e annotation android.support.test.filters.FlakyTest com.example.mobile.test/android.support.test.runner.AndroidJUnitRunner
V/InstrumentationResultParser: INSTRUMENTATION_RESULT: stream=
V/InstrumentationResultParser: 
V/InstrumentationResultParser: Time: 0,001
V/InstrumentationResultParser: 
V/InstrumentationResultParser: OK (0 tests)
V/InstrumentationResultParser: 
V/InstrumentationResultParser: 
V/InstrumentationResultParser: INSTRUMENTATION_CODE: -1
V/InstrumentationResultParser: 
0 tests on SM-A310F - 7.0
I/XmlResultReporter: XML test result file generated at TEST-SM-A310F - 7.0-mobile.xml. Total tests 0, 
V/ddms: execute 'am instrument -w -r   -e annotation android.support.test.filters.FlakyTest com.example.mobile.test/android.support.test.runner.AndroidJUnitRunner' on '31006b2f91c74311' : EOF hit. Read: -1
V/ddms: execute: returning

com.android.builder.testing.ConnectedDevice > No tests found.[SM-A310F - 7.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).
05:00:56 I/XmlResultReporter: XML test result file generated at TEST-SM-A310F - 7.0-mobile.xml. Total tests 1, failure 1, 
05:00:56 V/ddms: execute: running pm uninstall com.example.mobile.test
05:00:58 V/ddms: execute 'pm uninstall com.example.mobile.test' on '31006b2f91c74311' : EOF hit. Read: -1
05:00:58 V/ddms: execute: returning
05:00:58 V/ddms: execute: running pm uninstall com.example.mobile
05:01:00 V/ddms: execute 'pm uninstall com.example.mobile' on '31006b2f91c74311' : EOF hit. Read: -1
05:01:00 V/ddms: execute: returning

> Task :mobile:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.
4

0 回答 0