Airbnb Eli Hart Mar 17, 2020

Better Android Testing at Airbnb (Part 3)

Article Summary

Airbnb's Android team built a custom testing framework that runs thousands of automated tests across fragments without writing repetitive test code. Here's the architecture that makes it possible.

In Part 5 of their testing series, Airbnb engineer Eli Hart reveals the technical implementation behind their integration testing framework. This deep dive covers how they built on top of Espresso to automate screenshot and interaction tests at scale.

Key Takeaways

Critical Insight

Airbnb created a testing architecture where one Activity processes all mocked fragments automatically, turning complex integration tests into single line declarations while solving idle detection and error handling challenges.

The next article reveals the common sources of test flakiness they discovered and how they solved them at the root cause level.

About This Article

Problem

Espresso's standard idle detection missed asynchronous work happening in Airbnb's fragments. Epoxy was diffing RecyclerView changes on background threads, and Espresso couldn't see it. This caused tests to fail randomly with unpredictable timeouts.

Solution

Eli Hart's team wrote custom idle detection that posted Runnables to Handler queues and checked Handler().looper.queue.isIdle across multiple threads. They added timeout systems and frame-delay enforcement to catch all the async operations that Espresso was missing.

Impact

Developers could run thousands of automated tests without manually waiting for async work to finish. This cut down the debugging overhead since they no longer had to chase generic 'process crashed' errors through device logcat.