If I:
connectedAndroidDebugTest
Gradle task (from inside Android Studio or via gradlew
)The app winds up being uninstalled by the test run. I get that behavior even if I add a testApplicationId
value to defaultConfig
to have the test code use a different application ID.
How do I stop that behavior? How can I run instrumented tests from the command line, without disturbing an existing app installation?
The connectedCheck
task has the type DeviceProviderInstrumentTestTask
. For a simple test run on one device it uses a SimpleTestRunner
, which in
turn uses a SimpleTestRunnable
to actually execute the test. Here you find a structure of
try {
// connect to device
// install all APKs
// run tests
} catch(Exception e) {
// handle error
} finally {
// get test report
// uninstall all APKs
// disconnect from device
}
I'm not perfectly sure if I've found the most recent implementations, but this exact behavior dates back several years. So I guess you can't achieve what you're asking for.
Maybe try to run it via adb
like this:
adb shell am instrument -w com.android.demo.app.tests/android.support.test.runner.AndroidJUnitRunner
It will not uninstall your app.
here it is described in more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With