Screenshot tests

Testing Mid-level Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Pick the fix

A button's padding change slipped into release unnoticed. Unit tests passed. What would have caught it cheaply?

Options
Hint 1 of 1

Which kind of test sees pixels?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Screenshot tests of the design-system button in its states

Correct. A pixel diff would have shown the padding change in review.

Why not the others?
  • B More unit tests on the ViewModel. Padding isn't ViewModel logic.
  • C Espresso tests asserting the button exists. It existed; it just looked wrong.
  • D Manual QA on every release. Slow and easy to miss.

30-second answer

A screenshot test renders a composable or screen to an image and compares it with a stored reference, failing when pixels change. Tools such as Compose Preview Screenshot Testing, Paparazzi and Roborazzi run them on the JVM without a device. They catch visual regressions in design-system components and screens across themes, font sizes and locales that assertion tests miss.

Practise saying it · 30 s. No recording, just a timer

Explain screenshot tests.

Say your answer out loud, then check which of these points you covered:

  • Compare renders with references
  • JVM tools like Paparazzi, Roborazzi
  • Cover states and configurations
  • Review diffs

Deep dive

Record references on one machine setup; rendering differences across OSes cause noise.

Cover states (loading, error, long text) and configurations (dark, large font, RTL).

Review diffs in pull requests like code.

Keep them focused; screenshotting every screen with live data is brittle.

Common mistakes

  • Recording references on different machines and fighting flaky diffs.
  • Only screenshotting the happy path.
  • Updating references without reviewing the diff.

Senior take & follow-ups

Say where they shine (design systems, configurations) and how to keep them stable.

Follow-up questions

Think of your answer first, then open the hint.

  1. Why do JVM screenshot tests help?

    Show hint

    Fast and device-free, so they run on every pull request.

  2. What configurations are worth covering?

    Show hint

    Dark mode, large font scale, RTL and small screens.

Suggest a fix if something here is wrong or out of date.