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:

image

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.

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: 23 November 2024