Android测试用例无法在调试模式下工作

问题描述 投票:5回答:3

我无法调试android Instrumentation测试用例(使用espresso和UiAutomator)

但早期的测试用例调试工作正常,但最近的更新它不再起作用了。它总是在实例化单元测试enter image description here时受到打击

我可以在命令窗口中看到它正在尝试启动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
android android-studio android-testing android-instrumentation
3个回答
0
投票

如果我使用AndroidOrchestrator,对我来说同样的事情。如果你真的不需要用它来运行测试,或者至少在你想要调试的时候关掉它。

(已经很久了,但只是为了其他可能会陷入这个问题的人)


0
投票

正如@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'
  }
}
...

-1
投票

问题是一些配置文件没有在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,这对我来说没有用)

© www.soinside.com 2019 - 2024. All rights reserved.