2

Earlier to ensure that the app's state is completely cleared between tests we used in gradle the command:

testInstrumentationRunnerArguments clearPackageData: 'true'

In gradle 7.0.3 and higher this command has been already deprecated doesn't work:

@Incubating
@Deprecated(message = "Replaced by testInstrumentationRunnerArguments property")
public abstract fun testInstrumentationRunnerArguments(
    args: Map<String, String>
): Unit
Deprecated:
Replaced by testInstrumentationRunnerArguments property
  Gradle: com.android.tools.build:gradle-api:7.0.3 (gradle-api-7.0.3-sources.jar)

How to clear the state between instrumented tests in gradle now?

Stanly T
  • 964
  • 1
  • 12
  • 30
  • Are you sure, that your code has the same configuration as [here](https://developer.android.com/training/testing/instrumented-tests/androidx-test-libraries/runner#enable-gradle)? It works in the [android testing sample](https://github.com/android/testing-samples/blob/f533f189aaecb1fd9709fe3341d2a42ba422bc2c/runner/AndroidTestOrchestratorSample/app/build.gradle) – R. Zagórski Nov 03 '22 at 08:04
  • yes it does, and earlier it worked well and every time when i executed a class with tests, each of them started from logining, but now my tests remember the previous state. The second test is being started not from the authorizing, it is being started with the authorized user from first test. – Stanly T Nov 04 '22 at 15:48
  • @StanlyT, have you found the solution? I have to enable this property too. Also good doc has sample by using groovy dsl when all modern apps have to migrate to koltin dsl which has minor differences in syntax. Do you have a reference on the same field for kotlin dsl file (build.gradle.kts)? – Gleichmut Jun 30 '23 at 13:05

0 Answers0