Roborazzi Help

Build setup

Roborazzi is available on maven central.

This plugin simply creates Gradle tasks record, verify, compare and passes the configuration to the test.

build.gradle.kts

plugins

buildscript

Define plugin in root build.gradle.kts

plugins { ... id("io.github.takahirom.roborazzi") version "[version]" apply false }

Apply plugin in module build.gradle.kts

plugins { ... id("io.github.takahirom.roborazzi") }

root build.gradle.kts

buildscript { dependencies { ... classpath("io.github.takahirom.roborazzi:roborazzi-gradle-plugin:[version]") } }

module build.gradle.kts

plugins { ... id("io.github.takahirom.roborazzi") }

Use Roborazzi task

Use default unit test task

Description

./gradlew recordRoborazziDebug

./gradlew testDebugUnitTest after adding roborazzi.test.record=true to your gradle.properties file.

or

./gradlew testDebugUnitTest -Proborazzi.test.record=true

Record a screenshot
Default output directory is build/outputs/roborazzi
You can check a report under build/reports/roborazzi/index.html

./gradlew compareRoborazziDebug

./gradlew testDebugUnitTest after adding roborazzi.test.compare=true to your gradle.properties file.

or

./gradlew testDebugUnitTest -Proborazzi.test.compare=true

Review changes made to an image. This action will compare the current image with the saved one, generating a comparison image labeled as [original]_compare.png. It also produces a JSON file containing the diff information, which can be found under build/test-results/roborazzi.

./gradlew verifyRoborazziDebug

./gradlew testDebugUnitTest after adding roborazzi.test.verify=true to your gradle.properties file.

or

./gradlew testDebugUnitTest -Proborazzi.test.verify=true

Validate changes made to an image. If there is any difference between the current image and the saved one, the test will fail.

./gradlew verifyAndRecordRoborazziDebug

./gradlew testDebugUnitTest after adding roborazzi.test.verify=true and roborazzi.test.record=true to your gradle.properties file.

or

./gradlew testDebugUnitTest -Proborazzi.test.verify=true -Proborazzi.test.record=true

This task will first verify the images and, if differences are detected, it will record a new baseline.

./gradlew clearRoborazziDebug

This is not a test task.

Note: This is an experimental task. This task will clear the saved images. This task also deletes the cached images. Please be careful when using this task.

The comparison image, saved as [original]_compare.png, is shown below:

Comparison image highlighting the differences between the recorded and actual screenshots

You can check the test report in build/reports/roborazzi/index.html

image

This uses JetNew from Compose Samples. You can check the pull request introducing Roborazzi to the compose-samples here.

Gradle DSL Options (Optional)

Roborazzi uses module/build/outputs/roborazzi as the default directory for reference images and comparison images. You can customize these paths in your build.gradle file:

roborazzi { // Directory for reference images outputDir.set(file("src/screenshots")) // Directory for comparison images (Experimental option) compare { outputDir.set(file("build/outputs/screenshots_comparison")) } }

Separate output directories per variant/target (Experimental)

By default, every Roborazzi task shares a single output directory (build/outputs/roborazzi) and a single intermediate directory (build/intermediates/roborazzi). When multiple Roborazzi test tasks run in a single Gradle invocation (for example check, or Kotlin Multiplatform's allTests), their directory reads and writes can race with each other. On Gradle 9 this can hard-fail with Cannot access input property 'roborazziImageInput' (see #830).

Enabling separateOutputDirs gives each task slug its own subdirectory, so the tasks never share a directory:

roborazzi { // Experimental separateOutputDirs.set(true) }

The unit of separation is the recordRoborazzi<Slug> slug:

  • Android: the variant name, e.g. build/outputs/roborazzi/debug/, build/outputs/roborazzi/release/.

  • Kotlin Multiplatform: the target (× test run) name, e.g. build/outputs/roborazzi/desktop/.

The intermediate directory is separated the same way (e.g. build/intermediates/roborazzi/debug/). If you set a custom outputDir, the per-slug subdirectory is created under it.

Add dependencies

Description

Dependencies

Core functions

testImplementation("io.github.takahirom.roborazzi:roborazzi:[version]")

Jetpack Compose

testImplementation("io.github.takahirom.roborazzi:roborazzi-compose:[version]")

JUnit rules

testImplementation("io.github.takahirom.roborazzi:roborazzi-junit-rule:[version]")

Last modified: 12 July 2026