无法 运行 使用 InstrumentationRunListener 进行检测
Cant run instrumentation with InstrumentationRunListener
我正在尝试 运行 android 使用自定义 运行 侦听器进行仪器测试
这是我的听众
此 class 位于文件夹 app/src/androidTest/java/com/app/myapp
class AnnotationTestListener : InstrumentationRunListener() {
@Throws(Exception::class)
override fun testStarted(description: Description) {
super.testStarted(description)
val bundle = Bundle()
instrumentation.sendStatus(InstrumentationResultPrinter.REPORT_VALUE_RESULT_START, bundle)
}
}
然后我尝试通过以下方式调用检测侦听器
adb shell am instrument -w -r -e log true -e listener com.app.myapp.AnnotationTestListener com.app.myapp.test/androidx.test.runner.AndroidJUnitRunner | tee -a listeners/test.txt
但结果是
INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0
adb shell pm list instrumentation
产量
instrumentation:androidx.test.orchestrator/.AndroidTestOrchestrator (target=androidx.test.orchestrator)
instrumentation:com.app.myapp.test/androidx.test.runner.AndroidJUnitRunner (target=com.app.myapp)
如何解决问题?
实际问题是设备被锁定了。
不直观,但是错误信息也打印在错误logcat中。
我正在尝试 运行 android 使用自定义 运行 侦听器进行仪器测试
这是我的听众
此 class 位于文件夹 app/src/androidTest/java/com/app/myapp
class AnnotationTestListener : InstrumentationRunListener() {
@Throws(Exception::class)
override fun testStarted(description: Description) {
super.testStarted(description)
val bundle = Bundle()
instrumentation.sendStatus(InstrumentationResultPrinter.REPORT_VALUE_RESULT_START, bundle)
}
}
然后我尝试通过以下方式调用检测侦听器
adb shell am instrument -w -r -e log true -e listener com.app.myapp.AnnotationTestListener com.app.myapp.test/androidx.test.runner.AndroidJUnitRunner | tee -a listeners/test.txt
但结果是
INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0
adb shell pm list instrumentation
产量
instrumentation:androidx.test.orchestrator/.AndroidTestOrchestrator (target=androidx.test.orchestrator)
instrumentation:com.app.myapp.test/androidx.test.runner.AndroidJUnitRunner (target=com.app.myapp)
如何解决问题?
实际问题是设备被锁定了。
不直观,但是错误信息也打印在错误logcat中。