Airbnb Eli Hart Mar 3, 2020

Better Android Testing at Airbnb (Part 1)

Article Summary

Airbnb built a system that automatically tests every click in their Android app without writing a single Espresso test. Here's how they turned interaction testing from tedious to automatic.

Part 3 of Airbnb's testing series dives into their automated interaction testing framework. Instead of manually writing brittle Espresso tests for click handlers, they programmatically click every view, capture all resulting actions, and generate JSON reports that get diffed like screenshots.

Key Takeaways

Critical Insight

Airbnb's automated interaction testing generates comprehensive integration tests with zero manual Espresso code, catching regressions in click handlers that screenshot tests miss.

The framework even uses reflection to stabilize Android resource IDs across builds, solving a consistency problem that plagued their early attempts.

About This Article

Problem

Writing Espresso tests by hand for every interaction on a page takes forever. Most teams skip the small stuff like what arguments got passed or which network requests fired. This leaves a lot of interaction code untested, even though it makes up a big chunk of feature work.

Solution

Eli Hart's team built a system that walks through the view hierarchy using depth-first search, clicks every clickable and long-clickable view, captures the resulting actions through dependency injection mocks, and generates JSON reports. These reports get diffed using Happo's existing infrastructure.

Impact

With approval testing, developers can update tests in one click instead of writing traditional Espresso tests. This gives exhaustive coverage of interaction behavior and reuses the same CI setup that screenshot tests already use.