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 |
|---|---|---|
|
or
| Record a screenshot |
|
or
| Review changes made to an image. This action will compare the current image with the saved one, generating a comparison image labeled as |
|
or
| Validate changes made to an image. If there is any difference between the current image and the saved one, the test will fail. |
|
or
| This task will first verify the images and, if differences are detected, it will record a new baseline. |
| 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:
You can check the test report in build/reports/roborazzi/index.html
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:
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:
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 |
|
Jetpack Compose |
|
JUnit rules |
|