Member-only story
Android Screenshot Testing: Your Guide to Visual UI Verification
Compose Preview Screenshot Testing (CPST) tool in the context of Android development with Jetpack Compose.
Essentially, it’s a tool designed to automatically capture and compare screenshots of your Jetpack Compose previews against a set of baseline or reference screenshots. This allows you to visually verify that your composable UI elements render correctly across different states, configurations, and code changes
Verify visual properties. Test visual against reference screen. For visual verification during UI tests. More details her [doc].
Core Functionality
- Targeting Compose Previews: The tool specifically works with the
@Preview
annotations you use in your Compose code to render UI elements within the Android Studio IDE. - Automated Screenshot Capture: Instead of manually running your app on a device or emulator and taking screenshots of various preview states, this tool automates that process. You can configure it to capture screenshots of all or specific previews within your project.
- Reference Screenshot Management: The first time you run the screenshot tests (or when you make intentional UI changes), the captured screenshots are typically saved as your “reference” or “baseline” screenshots. These represent the expected visual appearance of your UI.
- Comparison Against Baselines: On subsequent test runs (especially after making code…