ScreenshotTestSuite

Added in 9.4.0-alpha02

@Incubating
interface ScreenshotTestSuite


A test suite to run Compose screenshot tests.

A ScreenshotTestSuite configures the execution environment and inputs required to render Compose previews and execute screenshot tests.

Example usage:

android {
testOptions {
screenshotTests {
create("myScreenshotTest") {
engineVersion = "1.0.0"
targetVariants.add("debug")
dependencies {
implementation(project(":my-test-helpers"))
}
}
}
}
}

Summary

Public functions

Unit

Configures the dependencies for this test suite.

Public properties

String?

The version of the screenshot validation engine.

MutableList<String>

Defines which variants this test suite targets.

Public functions

dependencies

Added in 9.4.0-alpha02
@Incubating
fun dependencies(action: AgpTestSuiteDependencies.() -> Unit): Unit

Configures the dependencies for this test suite.

Dependencies are added to the test suite's host (JVM) execution classpath. This enables the screenshot tests to access custom test helpers and preview providers during rendering.

Public properties

engineVersion

Added in 9.4.0-alpha02
var engineVersionString?

The version of the screenshot validation engine.

Specifies the version of the com.android.tools.screenshot:screenshot-validation-junit-engine artifact (published on the Google Maven repository) to use for layout rendering and screenshot validation.

This property is mandatory. A valid version must be provided; otherwise, a Gradle sync error will be reported.

targetVariants

Added in 9.4.0-alpha02
val targetVariantsMutableList<String>

Defines which variants this test suite targets.