问题
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