1

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

  • This answer can be useful for you - https://stackoverflow.com/questions/35306423/destroy-and-restart-activity-with-testing-support-library/36779019 – Anatolii Mar 26 '18 at 15:39

1 Answers1

1

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

Aleksander Mielczarek
  • 2,787
  • 1
  • 24
  • 43