I'm trying to create some baseline profiles for my Android app that are a bit more meaningful than simply startActivityAndWait()
My app starts off in an uninitialised state but once the user has chosen a destination this is stored in DataStore Preferences and you then no longer see the initial screens.
This means that running the BaselineProfileRule for the subsequent iterations fail because the initial buttons etc. are no longer applicable.
Is there a way to clear the app data between test runs with the BaselineProfile tests? I've tried adding InstrumentationRegistry.getInstrumentation().uiAutomation.executeShellCommand("adb shell pm clear *packageName*")
in the test but it doesn't seem to have any effect.
I also tried adding testInstrumentationRunnerArguments clearPackageData: 'true'
to the benchmark build.gradle but this was also ineffective.
A workaround I've been using to handling this is
And then, inside setup block: