I'm trying to execute a Test Suite but I need for my study to have the app in a cleared state before each test. Using Gradle's connectedCheck the app just resumes before each test, I've used Orchestrator to set the clear argument to true in order to have the data erased after a test but if I do execute all tests in a package at the same time it shows that the app isn't really being cleared up between executions.

Do you have any suggestions as to why I can accomplish this on either android studio or command line?

I've also tried to solve the issue by

  • implementing a ClearData annotation (doesn't work)
  • implementing a clearData task which is only executed after the first test

UPDATE Apparently I've found what was wrong with the testInstrumentationRunnerArguments clearPackageData: 'true', I've updated the orchestrator version from 1.0.1 to 1.0.2 and it now works, clearing the app data before each test run.

1 Answers

Community On

I've managed to solve my problem by updating the Orchestrator Version as it follows:


defaultConfig {
    testInstrumentationRunner = 'android.support.test.runner.AndroidJUnitRunner'

    // The following argument makes the Android Test Orchestrator run its
    // "pm clear" command after each test invocation. This command ensures
    // that the app's state is completely cleared between tests.
    testInstrumentationRunnerArguments clearPackageData: 'true'
testOptions {
  dependencies {
    androidTestUtil 'com.android.support.test:orchestrator:1.0.2'


Issue was with the previous version of orchestrator which as 1.0.1, not sure why.