punk_fusion92
punk_fusion92

Reputation: 47

When running espresso tests, app resumes instead of restarting

When I run multiple espresso tests, I find that the app does not restart but starts from the same location that it is left off. How to make it start from the beginning everytime

Upvotes: 1

Views: 1143

Answers (1)

Aleksander Mielczarek
Aleksander Mielczarek

Reputation: 2825

Consider Android Test Orchestrator. It will clear all data and restart Instrumentation between each test.

Add to app Gradle:

android {
  defaultConfig {
   ...
   testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 }

  testOptions {
    execution 'ANDROID_TEST_ORCHESTRATOR'
  }
}

dependencies {
  androidTestImplementation 'com.android.support.test:runner:1.0.1'
  androidTestUtil 'com.android.support.test:orchestrator:1.0.1'
}

And then run it as follows:

./gradlew connectedCheck

Upvotes: 1

Related Questions