Run Connectedandroidtest And Skip Uninstall
Solution 1:
Looking at the sorce of gradle plugin there is no way to prevent uninstalling app at the end of test task. You can check that in SimpleTestCallable
class of android gradle plugin.
From what i see there are two options to acchive what you want.
First one is to reinstall app after your connected check is done. Command to do that would look something like this. ./gradlew connectedCheck installDebug installDebugAndroidTest
This will execute test on device and delete apps from it. But after that it will reinstall app and test app. So app will still be removed and then installed which means a bit of owerhead but at least apps will not be recompiled twice since you are executing in same gradle execution.
Second option is to not use gradle for executing tests but use adb instead.
To do this you first need to install app and test app through gradle.
./gradlew installDebug installDebugAndroidTest
After that you can execute tests through adb. by caling adb shell am instrument -w com.example.test/android.support.test.runner.AndroidJUnitRunner
.
When this is done you can run your cli tests since both app and test app are still installed.
With second approach you would lose all the benefits of executing test wit gradle. Such as code coverage and executing in multiple proceses, etc.
Post a Comment for "Run Connectedandroidtest And Skip Uninstall"