Android Test cases not working in debug mode

那年仲夏 提交于 2020-12-30 08:01:03

问题


I am not able to debug android Instrumentation test cases (using espresso & UiAutomator)

But earlier test cases the debugging was working fine but with recent update it is not working anymore. It gets always struck up at instantiating unit test

I can see in command window that it's trying to launch 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

回答1:


The same thing for me in case i use AndroidOrchestrator. Turn it off if you dont really need to run the tests with it or, at least, when you want to debug.

(It has been so long time but just for the others who may fall latterly into this problem)




回答2:


As @PhạmLam mentioned, turning off Android Test Orchestrator worked for me.

To "turn off", I just comment out the execution 'ANDROIDX_TEST_ORCHESTRATOR' line in build.gradle when I want to debug:

...
android {
  defaultConfig {
   ...
   testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
   testInstrumentationRunnerArguments clearPackageData: 'true'
 }

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



回答3:


The problem is with some config file which is not tracked in git (so not able to figure out right now, Will do it when have free time)

adb shell am instrument -w -r -e debug true -e class PACKAGE_NAME.LanguageScreenTest#testSelectImportant PACKAGE_NAME**.test**/android.support.test.runner.AndroidJUnitRunner

when debug parameter is true test cases do not work in debug mode and it will struck on above state

but when this parameter is false it works

To solve this problem I have to use another clone of same repository (I had also tried deleting .idea and .gradle in same workspace which did not worked for me)



来源:https://stackoverflow.com/questions/39034929/android-test-cases-not-working-in-debug-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!