DEV Community

myougaTheAxo
myougaTheAxo

Posted on

Screenshot Testing in Jetpack Compose with Roborazzi

Screenshot Testing in Jetpack Compose with Roborazzi

Screenshot testing ensures UI consistency across releases. Roborazzi is a snapshot testing tool for Jetpack Compose that captures golden images and compares against new renders.

Setup

testImplementation("io.github.takahirom:roborazzi:1.x")
Enter fullscreen mode Exit fullscreen mode

Basic Screenshot Test

@get:Rule
val roborazziRule = RoborazziRule()

@Test
fun captureScreenshot() {
    composeTestRule.setContent {
        MyScreen()
    }
    roborazziRule.captureRoboImage()
}
Enter fullscreen mode Exit fullscreen mode

CI/CD Integration

Compare screenshots in GitHub Actions:

- name: Compare Roborazzi
  run: ./gradlew verifyRoborazziScreenshots
Enter fullscreen mode Exit fullscreen mode

Roborazzi detects pixel-level changes, preventing accidental UI regressions during refactoring.


8 production-ready Android app templates on Gumroad.
Browse templatesGumroad

Top comments (0)