Thumbtack Emily Fujimoto Dec 18, 2020

Using Android Screenshot Tests To Verify View Correctness

Article Summary

Emily Fujimoto from Thumbtack reveals how her team caught critical layout bugs that traditional testing completely missed. The solution? Screenshot tests that verify what your UI actually looks like, not just what elements exist.

Thumbtack's Android team struggled with UI testing for years. Robolectric tests required tons of boilerplate and couldn't verify if views actually looked correct—just whether elements were visible. They needed a better way to catch visual regressions before shipping.

Key Takeaways

Critical Insight

Screenshot testing using Facebook's Android library fills critical gaps in UI verification by comparing rendered images against reference screenshots, catching visual regressions that traditional assertion-based tests cannot detect.

The team discovered unexpected benefits beyond bug catching that changed how they review code and share progress with designers.

About This Article

Problem

Thumbtack's Android team used Robolectric tests to verify UI views, but these tests couldn't catch visual problems. They required at least one assertion per UI element and missed issues like text wrapping and overlapping views.

Solution

Emily Fujimoto's team adopted Facebook's Screenshot Tests for Android library and built a custom Python script. The script rendered views on devices, generated reference images, and compared them against new screenshots to identify visual differences.

Impact

Screenshot tests found layout problems during Constraint Layout library upgrades and tinting changes that Robolectric tests had missed. The team also eliminated the need for extensive assertion lists in their test code.