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
- System automatically clicks every view and records Fragment transactions, network requests, and state changes
- JSON reports capture interaction behavior with approval testing for one-click test updates
- Dependency injection intercepts custom systems (logging, network, database) without touching production code
- View hierarchy resets after each click to test interactions in isolation
- Happo integration combines JSON diffs with screenshot tests in single CI report
Airbnb's automated interaction testing generates comprehensive integration tests with zero manual Espresso code, catching regressions in click handlers that screenshot tests miss.
About This Article
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.
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.
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.