0

Im testing android app written in compose using cucumber and gherkin. My app is checking for shared prefs during splash screen to decide what fragment it should show. I want to do clean test app run every scenario/test but only first test under cucumber is working fine, Im starting my activity (single activity app), but only first run is clearing my app shared prefs, every next is not which breaks my Cucumber Background and next all scenarios. Maybe there is any other option that I could do to have fresh installation etc every scenario, need help

   val composeRule = createAndroidComposeRule<MainActivity>()
   
   @Given("launch app")
   fun launchApp() {
     with(composeRule) {
      activityRule.scenario.onActivity {
        // clear app shared prefs
        // do other stuff
      }
     }
   }

  • don't you miss the `@get:Rule` annotation above the `composeRule` property? If you need to clear the app Shared Prefs between tests then you can go with Gradle flag: `testInstrumentationRunnerArguments = [clearPackageData: 'true' ]` – gary0707 Dec 13 '22 at 14:16

0 Answers0