Test Reuse based on Adaptive Semantic Matching across Android Mobile Applications

Shuqi Liu, Yu Zhou, Tingting Han, Taolue Chen

TL;DR

TRASM (Test Reuse based on Adaptive Semantic Matching) is a novel framework designed to transfer GUI tests between similar Android applications (e.g., from one To-Do list app to another). By combining an adaptive matching strategy with automated event deduplication, it significantly improves the success rate and speed of test migration compared to existing state-of-the-art tools.

What Problem Does This Paper Address?

Graphical User Interface (GUI) testing is essential for mobile apps but notoriously labor-intensive. While automatic test generation exists, a more efficient route is test reuse: taking a test suite designed for "App A" and running it on "App B" within the same category.

However, test reuse often fails because:

  1. Semantic Mismatch: Widgets (buttons, text fields) might have different labels or internal IDs across apps, even if they perform the same function.
  2. Layout Differences: A "greedy" matching algorithm might pick the most similar-looking widget on a screen, but that widget might lead to the wrong app state.
  3. Functional Redundancy: One app might have a "Welcome" or "Tutorial" screen that the other lacks. If the test tries to "click through" a screen that isn't there, the entire test fails.

Methods

The authors propose TRASM, which introduces two major innovations over previous methods like CRAFTDROID:

  • GUI Events Deduplication: Before running the test on the target app, TRASM identifies and removes redundant events. For example, if the source app requires a "Next" click on a boot page that the target app doesn't have, TRASM detects this mismatch and skips the step to maintain the test's flow.
  • Adaptive Semantic Matching: Instead of just picking the widget with the highest similarity score (the "greedy" approach), TRASM uses an adaptive strategy. It records instances where similarity scores are low or ambiguous. If a test path fails, it uses a Window Transition Graph (WTG)—a map of the app's screens and buttons—to backtrack and "rematch" events with better candidates that are actually reachable in the current app state.
  • Semantic Calculation: To compare widgets, TRASM extracts attributes (text, resource-id, class) using the adb tool and calculates similarity using Word2Vec models, which understand that words like "task" and "todo" are semantically related.

Datasets

The study evaluated TRASM using a benchmark dataset of 15 Android applications across three categories:

  • Browsers (e.g., Lightning, Firefox Focus)
  • Tip Calculators (e.g., Simple Tip Calculator)
  • To-Do Lists (e.g., Minimal, Shopping List)

These apps were sourced from Google Play and F-Droid. The researchers tested six specific functionalities (e.g., "Add task," "Calculate total bill") across 30 different test cases.

Key Insights and Ideas

  • The "Greedy" Trap: Most existing tools fail because they are too "short-sighted." By picking the best-looking match right now, they often miss the correct widget needed to progress the test later. TRASM’s "adaptation" allows it to be more flexible.
  • Reachability is King: A widget might look 99% similar to the source, but if it doesn't lead to the next required screen, it's a bad match. Integrating the Window Transition Graph (WTG) ensures that matches are functionally viable, not just visually similar.
  • Less is More: Deduplication isn't just about speed; it's about robustness. Removing "meaningless" events that don't exist in the target app prevents the test runner from getting "lost" in the UI.

Key Results

TRASM was compared against the baseline tool CRAFTDROID with impressive results:

  • Higher Precision: TRASM improved GUI event matching precision by 5% to 15% across different functionalities.
  • Better Success Rates: For complex tasks like "Calculate total bill," the success rate of reused tests increased by 10%.
  • Significant Speedup: TRASM is much faster. In one scenario (calculating a bill), CRAFTDROID took 2,581 seconds, while TRASM finished in just 890 seconds—a 65% reduction in time. This is largely due to TRASM's ability to store explored paths and avoid redundant calculations.

Limitations and Future Work

The authors acknowledge a few areas for improvement:

  • Computational Overhead: While TRASM is generally faster due to path storage, the adaptive strategy could theoretically increase time consumption if it has to search through many candidate widgets for a difficult match.
  • Generalization: The current study focused on three app categories. Future work aims to verify TRASM on a wider variety of more complex applications.
  • Oracle Generation: The authors plan to investigate how to automatically determine if a reused test actually "passed" (oracle generation) more accurately in future iterations.

Summary updated

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
b21 — Calculate total bill with tip (Tip Calculator)TRASMGUI event precision93%Gui Test Reuse · split: test · functionality=b21
Source quote
L228: TRASM │ 93% │ 100% │ 100% │ 90% │ 18/20(90%)
b21 — Calculate total bill with tip (Tip Calculator)TRASMAverage test reuse time890 secondsGui Test Reuse · split: test · functionality=b21
Source quote
L249: Efficiency. Figure ~\ref{fig4} lists the average test reuse time on each functionality. It is obvious that the average time spent on reuse testing of TRASM is less than that of CRAFTDROID for each functionality. Even the most significant effect is that for functionality b21, the average reuse test of CRAFTDROID takes 2581 seconds (43 minutes), while our TRASM only takes 890 seconds (15 minutes), which is close to 35% of the time of CRAFTDROID. In summary, the results are attributed to two factors. One is that the storage of explored paths avoids repeated time consumption, and the other is that the adaptive strategy improves the efficiency of widget matching. The above results prove that we can break through the limitation on efficiency in CRAFTDROID.
Reported baseline / comparator measurements (1)
BenchmarkMethodMetricScoreProtocol / Evidence
b21 — Calculate total bill with tip (Tip Calculator)CRAFTDROID baselineAverage test reuse time2581 secondsGui Test Reuse · split: test · functionality=b21
Source quote
L249: Efficiency. Figure ~\ref{fig4} lists the average test reuse time on each functionality. It is obvious that the average time spent on reuse testing of TRASM is less than that of CRAFTDROID for each functionality. Even the most significant effect is that for functionality b21, the average reuse test of CRAFTDROID takes 2581 seconds (43 minutes), while our TRASM only takes 890 seconds (15 minutes), which is close to 35% of the time of CRAFTDROID. In summary, the results are attributed to two factors. One is that the storage of explored paths avoids repeated time consumption, and the other is that the adaptive strategy improves the efficiency of widget matching. The above results prove that we can break through the limitation on efficiency in CRAFTDROID.
BibTeX
@inproceedings{liu2022test,
  author = {Shuqi Liu and Yu Zhou and Tingting Han and Taolue Chen},
  title = {{Test Reuse based on Adaptive Semantic Matching across Android Mobile Applications}},
  booktitle = {QRS},
  year = {2022},
  doi = {10.1109/qrs57517.2022.00076},
}
Figure