-
Notifications
You must be signed in to change notification settings - Fork 221
Hints and FAQ
Running gradle recordMode screenshotTests will run the task that was set in the gradle plugin extension field "screenshots", e.g. connectedAndroidTestTarget=connectedProdDebugAndroidTest. This will run all instrumentation tests instead of just the screenshot tests. One way to run only the screenshot tests is to set the DefaultProductFlavor field setTestInstrumentationRunnerArguments in your build.gradle file. This field allows us to set arguments for the am instrument command. In this example, we have our app package called com.example.app where our screenshot tests are in the package com.example.app.tests.screenshots.
android {
defaultConfig {
if (project.gradle.startParameter.taskNames.contains("screenshotTests")) {
Map<String, String> map = new HashMap<String, String>();
map.put("package", "com.example.app.tests.screenshots");
setTestInstrumentationRunnerArguments map
}
...
}
...
}
When running gradle recordMode/verifyMode screenshotTests, this statement will satisfy the if conditional and pass the argument package=com.example.app.tests.screenshots to the am instrument command, e.g. adb shell am instrument -w -e package com.example.app.tests.screenshots which will execute any test case class that are below this package.