TL;DR
This paper introduces CAT, a novel Android GUI testing framework that specifically targets app updates by analyzing code changes to identify affected GUI elements. CAT then generates focused, length-3 event sequences to rigorously test these elements, demonstrating superior effectiveness in bug detection and interaction compared to existing general-purpose GUI testing tools.
What Problem Does This Paper Address?
Android apps are constantly updated to keep pace with user demands, hardware advancements, and business needs. Ensuring the correctness and stability of these updates through testing is crucial. While automated GUI event generation tools exist, they often lack focus, exploring the app's entire functionality rather than prioritizing areas impacted by recent changes. This can lead to inefficient testing, missing update-specific bugs, and a lengthy process to even reach the modified parts of the app. Existing regression test selection techniques, while focusing on changes, don't generate new tests; they only select from existing ones. This paper addresses the gap for a tool that can automatically generate targeted GUI tests specifically for app updates.
Methods
CAT employs a multi-step approach:
- Input Preprocessing: It takes an Android app's APK file and a JSON file detailing code changes. Using tools like FlowDroid and Soot, it constructs a call graph and identifies layout files.
- GUI Element and Function Mapping: CAT builds a comprehensive map linking Java functions to GUI elements and their associated Activities. This is achieved by analyzing the call graph and identifying event listeners.
- Change Impact Analysis: This is the core innovation. CAT traces the impact of identified code changes (from the JSON input) down to specific GUI elements. It traverses the combined GUI-function map to pinpoint "target GUI elements" that are affected by the update. This step can handle both static and dynamic GUI elements.
- Test Input Generation: For the identified target GUI elements, CAT generates length-3 event sequences. This is a departure from single-event generation, aiming for more rigorous testing by exploring different contexts leading to the target element. It leverages a modified version of the DroidBot tool for this phase.
- Test Execution: The generated event sequences are executed on an Android emulator. The framework includes mechanisms to re-enter target states if the execution deviates, ensuring focused testing.
Datasets
The authors evaluated CAT on a dataset of 21 publicly available open-source Android Apps from the F-Droid App market. For each app, they manually identified changes by reading commit comments for the APK file release and provided these changes as a JSON file to CAT. This dataset is available at https://github.com/CATAndroidTesting/CAT.
Key Insights and Ideas
- Focusing on Change is Key: The most significant insight is that by precisely identifying GUI elements affected by code changes, testing can become dramatically more efficient and effective. General-purpose tools are like searching for a needle in a haystack; CAT helps you find the haystack where the needle is likely to be.
- Length-3 Event Sequences for Rigor: Generating sequences of three events, rather than single events, allows for testing the target GUI element in more varied contexts. This proved crucial for uncovering bugs that are sensitive to the order of operations.
- Bridging Code and GUI: The ability to trace changes from source code functions directly to affected GUI elements is a powerful capability that existing tools either lack or do not emphasize for update testing.
- Dynamic GUI Elements are a Challenge, but Solvable: While dynamic GUI elements (those not statically defined in XML) pose a challenge, CAT's approach of integrating with DroidBot's exploration allows it to identify and interact with them at runtime.
Key Results
- Faster Interaction: CAT reached target GUI elements significantly faster than DroidBot (DB) and DroidMate (DM). On average, CAT needed only 83 events to first interact with a target element, compared to 286 for DB and 258 for DM.
- More Frequent Interaction: CAT interacted with target GUI elements much more frequently, averaging 69 interactions per app, versus 5 for DB and 3 for DM.
- Bug Detection: CAT successfully uncovered previously undetected bugs in 2 out of 21 apps (World Weather and BeeCount). DB found a bug in World Weather but not BeeCount, and DM found no bugs.
- Change Impact Analysis: CAT could automatically identify target GUI elements for 18 out of 21 apps statically, and for the remaining 3 apps with dynamic GUI elements, it identified them during runtime exploration. This analysis was completed within 30 seconds per app.
- Code Coverage: CAT achieved 100% coverage of change-affected Java functions for most apps, similar to DB and DM, indicating that its targeted approach effectively exercises the modified code.
Limitations and Future Work
- Threats to Validity: The authors acknowledge potential threats to:
- Internal Validity: Bugs in CAT's implementation (mitigated by code reviews and public availability).
- External Validity: The dataset of 21 apps might not be fully representative of all Android apps (mitigated by using diverse apps).
- Construct Validity: The restriction of 1000 events for all tools might affect comparability (though they argue it affects all tools uniformly).
- Limited Comparison: Only DB and DM were used for comparison, and including other tools would strengthen validity.
- Future Work: The authors plan to optimize CAT's exploration strategy to enter target states sooner and reduce events spent in non-target states. They also aim to further improve the framework's exploration strategy.
Summary updated