Test Script Intention Generation for Mobile Application via GUI Image and Code Understanding

Shengcheng Yu, Chunrong Fang, Jia Liu, Zhenyu ChenACM Transactions on Software Engineering and Methodology 2025

TL;DR

Understanding mobile app test scripts is a major bottleneck for developers. This paper introduces TESTINTENTION, a novel approach that leverages both GUI image analysis and source code understanding to automatically generate natural language descriptions of test script intentions, significantly reducing the time developers spend deciphering them.

What Problem Does This Paper Address?

Mobile app testing heavily relies on GUI test scripts, which simulate user interactions. However, these scripts are often poorly commented, making it difficult for developers to understand their purpose, especially when maintaining or modifying them. Existing code summarization techniques aren't directly applicable because test scripts lack explicit business logic and are loosely coupled to the app via widget selectors. This gap leads to a significant time investment for developers trying to comprehend these scripts, hindering efficient app development and maintenance.

Methods

TESTINTENTION tackles this problem by combining two main components:

  • GUIINTENTION: This part focuses on understanding the visual and textual information of the app's GUI. For widgets identified by XPath (a common but less precise selector), it extracts textual information from GUI layout files and uses OCR on screenshots. Crucially, for widgets lacking explicit text, it employs a deep learning model with an "Encoder-Decoder" structure (based on CNNs and LSTMs) to generate "widget intentions" from images.
  • CODEINTENTION: This component handles widgets identified by IDs, which are more directly linked to app functionality. It first maps these IDs to corresponding response methods in the app's source code using a novel algorithm that leverages static analysis. Then, it uses a "code2seq" inspired deep learning model to generate natural language descriptions of these response methods, effectively inferring the code's intention.

These two components work together, with their results merged and deduplicated to produce a comprehensive test script intention report. The approach formalizes test scripts as an "operation sequence" model, breaking down each step for detailed analysis.

Datasets

  • Rico Dataset: Used for collecting widget images for training and evaluating the widget image understanding model.
  • AndroZooOpen Dataset: A large collection of open-source Android apps used to select 50 apps for the experiment. These apps were chosen based on criteria like being pure Java, not video games, and having high popularity.
  • Custom Test Scripts: 500 test scripts (10 per app) were developed by experienced mobile app testers for the 50 selected apps. These scripts were designed to cover specific functionalities and were manually labeled with ground-truth intentions.

Key Insights and Ideas

  • The Power of Combined Modalities: The paper strongly emphasizes that neither GUI information alone nor code information alone is sufficient for accurate test script intention generation. Combining both provides a more holistic understanding.
  • Bridging the Gap for XPath Selectors: The GUIINTENTION component, particularly its use of image understanding for widgets without explicit text, is a key innovation for handling the common challenge of XPath-based selectors.
  • Automating the Manual Process: TESTINTENTION effectively automates the laborious manual process of deciphering test scripts by mapping operations to response methods and inferring intentions.
  • Transition Operations are Tricky: The study identified "transition operations" (like scrolling) as a challenge, as they often lack explicit intentions and primarily serve to link other operations. This highlights a nuanced aspect of test script analysis.

Key Results

  • Significant Time Savings: A user study showed that TESTINTENTION reduced the average task completion time for understanding unfamiliar mobile app GUI test scripts by 79.88%. Participants using TESTINTENTION-generated intentions needed only 17.13 seconds on average, compared to 85.13 seconds for those without.
  • Improved Intention Generation: TESTINTENTION outperformed baseline approaches (including code summarization models like code2seq and LLM-based methods) on various metrics (BLEU, CIDEr, METEOR, ROUGE) for generating test script intentions. For example, its average BLEU score was 0.17, significantly higher than baselines.
  • Effective Operation Mapping: The system successfully mapped 71.6% of test script operations to their corresponding response methods or GUI information. GUIINTENTION was particularly effective, succeeding in 66.5% of all operations.
  • Widget Image Understanding Accuracy: The widget image understanding model achieved an accuracy of 97.46% in generating intentions for widget images.

Limitations and Future Work

  • Limited App Selection: The experiment used 50 apps, which, while diverse, might not cover all possible scenarios. However, the authors argue the selection criteria ensure generalizability.
  • Test Scenarios: The 10 test scripts per app might not cover all functionalities. The authors suggest future work could explore more diverse test scenarios.
  • Manual Effort in Data Labeling: While efforts were made to ensure label quality, the reliance on human annotators is an inherent limitation.
  • Transition Operations: The paper acknowledges that transition operations are difficult to interpret and do not have explicit intentions, suggesting this as an area for further investigation.
  • Test Oracles: The current work focuses on intentions and does not formally include test oracles (expected outcomes). Understanding test oracles is identified as a meaningful future research direction.
  • Adaptability: While the current implementation focuses on Java and Appium, the authors believe the core technologies can be adapted to other drivers and languages.

Summary updated

BibTeX
@article{yu2025test,
  author = {Shengcheng Yu and Chunrong Fang and Jia Liu and Zhenyu Chen},
  title = {{Test Script Intention Generation for Mobile Application via GUI Image and Code Understanding}},
  journal = {ACM Transactions on Software Engineering and Methodology},
  year = {2025},
  url = {https://openreview.net/forum?id=M4Mwb9n1t0},
}
Figure