DroidWalker: Generating Reproducible Test Cases via Automatic Exploration of Android Apps

Ziniu Hu, Yun Ma, Yangyang HuangarXiv 2017

Abstract

Automated testing tools for Android often struggle with reproducibility due to the dynamic nature of mobile UIs. We present DroidWalker, a tool that utilizes structural hashing of UI hierarchies to create a robust state model. By abstracting away transient content and focusing on layout structure, DroidWalker enables reliable navigation and reproduction of test cases even amidst minor UI changes. Evaluation on 20 open-source benchmarks and 5 commercial apps demonstrates that DroidWalker achieves superior code coverage compared to existing state-of-the-art tools and successfully reproduces real-world crashes.

Introduction

Automated app exploration tools are essential for stress-testing and crash detection. However, tools like Android's "Monkey" suffer from a lack of reproducibility. Because mobile apps are highly dynamic—where a new notification or updated news feed can shift UI elements—a recorded sequence of clicks often fails upon re-execution. A click intended for a "Submit" button might hit a "Cancel" button if the layout has shifted. This fragility hinders developers from reproducing reported failures or conducting effective regression tests.

Methods

DroidWalker addresses these challenges through a two-phase approach: exploration and reproduction. The system architecture coordinates several specialized components to build and navigate an app's state model.

The DroidWalker system architecture, illustrating the flow from the execution environment through the exploration and reproduction phases.
  1. State Identification via Structural Hashing: To handle UI dynamics, DroidWalker employs structural hashing. Instead of identifying screens by pixel data or text, it generates a hash based on the UI hierarchy's structure. This ignores specific data (e.g., a headline's text) while capturing the layout (e.g., the presence of a headline widget).
  2. Exploration Phase: A Depth-First Search (DFS) strategy is used to crawl the application and construct a Finite State Machine (FSM). Nodes represent UI states, and edges represent user actions. To improve efficiency, DroidWalker utilizes Android's Intent mechanism for backtracking, allowing it to jump directly to specific activities rather than relying solely on the "back" button.
  3. Reproduction Phase: When a target state (such as a crash) is identified, DroidWalker uses Breadth-First Search (BFS) on the generated FSM to find the shortest path of events to reach that state. A structural similarity algorithm with a tunable threshold allows the tool to tolerate minor UI changes during execution.

Results and Evaluation

The tool was evaluated using 20 open-source benchmarks and five high-complexity commercial apps, including AccuWeather and Fitbit. In head-to-head comparisons with state-of-the-art tools including A3E, GUIRipper, and PUMA, DroidWalker achieved significantly higher line coverage across the benchmark suite.

Comparison of code coverage achieved by DroidWalker against other Android test generation tools.

Furthermore, DroidWalker outperformed the native Android Monkey in commercial app testing. For instance, in the Fitbit app, DroidWalker covered 11 activities compared to the Monkey's 8. The tool also demonstrated practical utility by successfully reproducing a java.io.FileNotFoundException in Fitbit, generating a precise shortest-path test case to the specific profile picture selection screen where the crash occurred.

Conclusion

DroidWalker provides a robust framework for automated Android testing by bridging the gap between exploration and reproducibility. By focusing on structural UI characteristics rather than transient content, it offers a more resilient method for bug detection and regression testing. Future work will focus on refining similarity thresholds and handling more complex app dynamics like heavy animations.

Summary updated

BibTeX
@misc{hu2017droidwalker,
  author = {Ziniu Hu and Yun Ma and Yangyang Huang},
  title = {{DroidWalker: Generating Reproducible Test Cases via Automatic Exploration of Android Apps}},
  year = {2017},
  eprint = {1710.08562},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1710.08562},
}
Figure