Better Android Testing at Airbnb — Part 3: Interaction Testing

Interaction Testing

Eli Hart
17 min readadvanced
--
View Original

Overview

This article discusses the implementation of an automated interaction testing system at Airbnb for Android applications. It highlights the challenges of traditional testing methods and introduces a new approach that leverages Approval Testing techniques to enhance the testing of user interactions without writing extensive Espresso tests.

What You'll Learn

1

How to automate interaction testing for Android applications

2

Why traditional Espresso tests can be brittle and how to mitigate this

3

How to implement a JSON reporting system for interaction results

4

When to apply Approval Testing techniques in automated testing

Prerequisites & Requirements

  • Understanding of Android testing frameworks like Espresso
  • Familiarity with JSON and its manipulation(optional)

Key Questions Answered

What is the new approach to interaction testing introduced at Airbnb?
The article introduces an automated interaction testing system that detects changes in user interactions without the need for extensive manual Espresso tests. This system uses Approval Testing techniques to verify behavior and produces a JSON report detailing the results of each interaction.
How does the automated interaction testing system work?
The system programmatically clicks each view in the hierarchy, records the resulting actions, and generates a JSON report that maps each view to its onClick behavior. This allows for comprehensive testing of interactions without traditional test writing.
What are the benefits of using JSON for reporting interaction results?
Using JSON for reporting allows for easy diffing of test results, making it simpler to track changes in behavior over time. The structured format also enhances readability and consistency across test reports.
What challenges are associated with traditional interaction testing methods?
Traditional methods, such as Espresso tests, can be brittle due to manual identification of views, the need for scrolling in lists, and handling asynchronous results, which can lead to flaky tests and omitted details.

Technologies & Tools

Testing Framework
Espresso
Used for traditional interaction testing in Android applications.
Data Format
JSON
Used for reporting interaction results and tracking changes.

Key Actionable Insights

1
Implement an automated interaction testing system to reduce manual testing efforts.
By automating interaction tests, teams can save time and reduce the likelihood of human error, leading to more reliable testing outcomes.
2
Utilize JSON reporting to track interaction changes effectively.
JSON's structured format allows for easy comparison of test results, making it simpler to identify regressions and changes in behavior across different branches.
3
Leverage Approval Testing techniques to streamline test updates.
This approach minimizes the effort required to maintain tests, allowing for more comprehensive coverage without the burden of writing extensive test cases.

Common Pitfalls

1
Relying too heavily on manual Espresso tests can lead to brittle tests.
Manual tests often require constant updates as UI changes occur, which can lead to increased maintenance overhead and potential for missed regressions.

Related Concepts

Automated Testing Frameworks
Approval Testing Techniques
JSON Data Manipulation
Android UI Testing Best Practices