我无法调试android Instrumentation测试用例(使用espresso和UiAutomator)
但早期的测试用例调试工作正常,但最近的更新它不再起作用了。它总是在实例化单元测试时受到打击
我可以在命令窗口中看到它正在尝试启动PACKAGE_NAME **。test **
adb shell am instrument -w -r -e debug true -e class PACKAGE_NAME.LanguageScreenTest#testSelectImportant PACKAGE_NAME**.test**/android.support.test.runner.AndroidJUnitRunner
如果我使用AndroidOrchestrator
,对我来说同样的事情。如果你真的不需要用它来运行测试,或者至少在你想要调试的时候关掉它。
(已经很久了,但只是为了其他可能会陷入这个问题的人)
正如@PhạmLam所说,关闭Android Test Orchestrator为我工作。
为了“关闭”,我只想在调试时注释execution 'ANDROIDX_TEST_ORCHESTRATOR'
中的build.gradle
行:
...
android {
defaultConfig {
...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
}
testOptions {
// Comment out below line
// execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
}
...
问题是一些配置文件没有在git中跟踪(因此现在无法弄清楚,有空闲时会这样做)
adb shell am instrument -w -r -e debug true -e class PACKAGE_NAME.LanguageScreenTest#testSelectImportant PACKAGE_NAME **。test ** / android.support.test.runner.AndroidJUnitRunner
当debug参数为true时,测试用例在调试模式下不起作用,它将在上面的状态下触发
但是当此参数为false时,它可以正常工作
要解决这个问题,我必须使用相同存储库的另一个克隆(我也尝试在相同的工作空间中删除.idea和.gradle,这对我来说没有用)