A developer shares their experience building a custom screenshot testing library for Android after outgrowing the third-party Shot library. The post covers the mathematical complexity of UI component combinations in a design system, the decision to build an in-house solution, and a detailed technical walkthrough including: configuring ActivityScenario, extending AndroidJUnitRunner, capturing bitmaps from views, and writing a Gradle plugin that pulls screenshots from the emulator, performs pixel-by-pixel comparison with configurable tolerance, and generates an HTML diff report. Key practical challenges addressed include emoji rendering differences across API versions, flaky tests from deferred image loading, fixed-width rendering for consistency, and Windows path compatibility.

11m read timeFrom proandroiddev.com
Post cover image
Table of contents
#2. Integrating custom test configuration into AndroidJUnitRunnerGet Pavel Nestsiarenka ’s stories in your inbox#3. Functionality for test execution#4. Gradle Plugin for convenient test execution, screenshot comparison, and report generationConclusion
1 Comment

Sort: