Airbnb Eli Hart Mar 24, 2020

Better Android Testing at Airbnb (Part 4)

Article Summary

Airbnb's Android tests were failing randomly. The culprit? Everything from cached drawables to delayed runnables creating unpredictable test behavior.

In Part 6 of their testing series, Airbnb's Eli Hart reveals the hidden sources of test flakiness that plague screenshot and interaction testing. With tests running in unpredictable order via Flank, even small state leaks compound into major reliability issues.

Key Takeaways

Critical Insight

Airbnb achieved reliable Android testing by systematically eliminating flakiness sources at the framework level, from shared preferences to WebView mocking.

The team's approach to handling out-of-memory exceptions during 40,000 pixel screenshots reveals clever bitmap management strategies.

About This Article

Problem

Airbnb's test framework couldn't use Android Test Orchestrator because it made tests run seven times slower. Engineers had to manually clear shared state between tests and deal with memory leaks that appeared randomly across test shards.

Solution

Eli Hart's team built centralized wrapper APIs for async operations like RxJava's execute function and injected test Coroutine Scopes. This let the framework block or detect when asynchronous code finished in a predictable way.

Impact

Test shards now run in three minutes or less, and LeakCanary detection catches memory issues before they happen. This stopped the Out Of Memory exceptions that used to crash test processes after running many tests in a row.