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

9

我无法调试安卓仪器测试用例(使用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

你尝试过执行“无效缓存/重启”吗? - Aram Tchekrekjian
是的,我确实尝试了“无效缓存/重启”以及删除更新版本的工作室并安装旧版本,但似乎也没有起作用(还删除了系统中相关的文件)。 - Ankur
3个回答

2

如果我使用 AndroidOrchestrator,对我来说也是一样的。如果您不需要使用它运行测试,或者至少在调试时关闭它。

(虽然已经过了很长时间,但这是为其他人解决同样问题的参考)


2
正文:
如@PhạmLam所提到的,关闭Android Test Orchestrator对我有用。
“关闭”时,我只需在想要调试时注释掉build.gradle中的execution 'ANDROIDX_TEST_ORCHESTRATOR'行:
...
android {
  defaultConfig {
   ...
   testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
   testInstrumentationRunnerArguments clearPackageData: 'true'
 }

  testOptions {
    // Comment out below line
    // execution 'ANDROIDX_TEST_ORCHESTRATOR'
  }
}
...

1
这个工作,但为什么我不能在调试中使用编排器? - JBarbosa

0

问题出在某个配置文件上,该文件未被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文件,但没有成功)


遇到相同的问题,但是如何设置 -e debug false - Ninja
我进行了一次全新的检出。我没有探究原因,可能是某个未被Git跟踪的配置文件。 - Ankur

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接