Android Screenshot Testing on Autopilot
summary
Converts Jetpack Compose previews into runnable screenshot tests by using a KSP code generator that finds @Preview functions, emits JUnit 5 + Paparazzi test classes, and a custom Gradle plugin that mounts the generated folder as a test source set, injects compileOnly test deps, runs the record/verify tasks and then removes the deps. Implementation handles preview parameters (named via a PreviewParameterProvider), throws on duplicate names, and runs in real projects — producing over 1,000 PNGs with zero manual test code and ~6–8 minute full generation.
AI-written summary · about
chapters (14)
- 0:00Automated screenshot testing
- 1:09Manual testing problems
- 4:03Manual to automated workflow
- 7:36Test source set challenge
- 9:22Live demo setup
- 15:14Dependencies and annotations
- 16:59Gradle plugin compilation
- 20:33Auto-generating screenshot tests
- 23:00Preview parameters handling
- 27:00Results and impact
- 28:45Advanced config improvements
- 31:41CI integration
- 37:20Paparazzi future and Google's approach
- 40:44Incremental builds
related talks
40mUnderstand the mechanism! Screenshot-testing Compose previews in many variations
44mAutomating Screenshot Testing in Compose Multiplatform
23mAll your Compose @Previews to screenshot tests without instrumentation
35mEasy screenshot testing with Compose
38mMastering Screenshot Testing for Android Apps
19mLet's Preview! Jetpack Compose
19mSneak Peek at the Screenshot Testing Landscape in 2024
34mMastering Jetpack Compose Previews - Test your UI before it tests you!
