Mobile application function test generation method based on retrieval enhancement
By extracting domain knowledge from historical test cases using a retrieval-enhanced approach and combining it with a large language model to generate structured test cases, the challenges of semantic understanding and assertion generation in mobile application automated testing are solved, achieving efficient and reliable functional test generation.
Patent Information
- Application Number
- CN202511929387.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-03
AI Technical Summary
Existing automated testing methods for mobile applications cannot effectively understand the semantics of application functions, resulting in generated test cases that cannot accurately detect target functions. Furthermore, they lack the reuse of domain knowledge and assertion generation, which affects the quality and reliability of test cases.
A retrieval-enhanced approach is adopted, in which domain knowledge is extracted from historical test cases through semantic retrieval agents and knowledge fusion agents, and structured functional summaries are generated by combining large language models. Test cases, including events and assertions, are generated by perceptual interaction agents and decision generation agents that conform to the actual context.
It achieves high-quality automatic generation of functional test cases, solving the problems of difficult test case reuse, poor adaptability and lack of assertion generation in existing methods, thus improving the effectiveness and reliability of testing.
Smart Images

Figure CN121597589A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of mobile application development and testing technology, specifically, it relates to a method for generating mobile application function tests based on retrieval enhancement. Background Technology
[0002] Over the past decade, mobile applications have evolved into an indispensable form of software, experiencing explosive growth in both quantity and market size. By 2025, major app stores had over four million apps listed, and global app spending reached approximately $127 billion in 2024. Against this backdrop, building an effective quality assurance system is imperative, and functional testing, as a key means of verifying business logic and user experience, is becoming increasingly important.
[0003] Mobile applications primarily interact with other applications through a graphical user interface (GUI). Therefore, functional testing typically involves executing a series of ordered events (such as clicks and inputs) on GUI components, accompanied by corresponding assertions to verify whether the results meet the developer's expectations. However, existing automated testing for mobile applications mainly focuses on defect detection, lacking a semantic understanding of application functionality and unable to generate specific test cases for particular features. Currently, the creation of functional test cases still heavily relies on manual labor. This approach is not only inefficient and difficult to scale, but also directly impacts the quality and reliability of test cases due to differences in how different testers describe functional requirements and potential ambiguities. Therefore, how to automatically generate high-quality functional test cases has become a critical problem that urgently needs to be solved.
[0004] Despite the growing need for functional test automation, achieving high-quality functional test generation still faces two core challenges: Challenge 1: Acquisition and Reuse of Domain Knowledge. The creation of high-quality functional test cases heavily relies on the domain knowledge and experience of test experts. However, this knowledge often exists in the form of vague, unstructured natural language requirement descriptions and scattered historical test cases, making it impossible to effectively transform and reuse valuable domain knowledge, thus limiting the actual effectiveness of functional test automation.
[0005] Challenge 2: Semantic Understanding and Adaptation of Application Functions. Mobile application functions vary significantly, and the semantics, interaction logic, and business scenarios of their GUI components are highly complex and application-specific. Traditional methods struggle to understand the specific functional semantics of different applications, resulting in generated test cases that cannot accurately detect the target functions.
[0006] To address the above issues, existing research has proposed various functional test generation methods for different systems. In the Android system, Li et al. proposed a test generation method based on a matching model. This method relies on manually written test logic and manually selected application screenshots, selecting operation events appearing in the interface through model matching. However, this method only supports single click operations, limiting its application in complex real-world scenarios. DroidBot-GPT was the first to introduce a large language model, selecting operation events based on manually written test logic. AutoDroid, as an enhanced version of DroidBot-GPT, introduces an offline state relationship understanding mechanism to improve testing effectiveness. AppAgent learns the functional operation logic of the application and generates corresponding test cases through both autonomous exploration and observation of human demonstrations.
[0007] For iOS systems, both AXNav and ILvuUI use test logic and application screenshots as input, and leverage a vision-based large language model for event selection. For Windows systems, AssistGUI has a specially designed GUI test generation framework adapted to that system.
[0008] However, the core differences between existing methods and RAGDroid lie in two aspects. Regarding knowledge utilization, RAGDroid extracts domain knowledge by constructing a functional test dataset and retrieving similar test cases, while existing methods primarily rely on automatically exploring the target application, impacting test accuracy. In terms of test completeness, assertions are crucial for functional testing. RAGDroid can generate both events and assertions, while existing methods can only generate events, limiting their practical application value.
[0009] Based on different exploration strategies, mobile application defect detection methods can be divided into four categories: random testing, model-based methods, system testing methods, and learning-based methods. Representative works include Monkey, which uses random exploration; AIMDROID and Stoat, which combine static and dynamic analysis; SCENTEST, which is based on event knowledge graphs; and SynthesiSE, which can dynamically infer the representation of the Android model.
[0010] The core difference between RAGDroid and the four methods mentioned above lies in the fundamental difference in their research objectives. Existing methods mainly focus on general GUI exploration and defect detection, while RAGDroid focuses on the requirement verification of individual functions. By simulating real user interactions to generate functional test cases, it effectively solves the problem that the generation of test cases for specific functions relies heavily on manual design.
[0011] General-purpose large language models, exemplified by ChatGPT, have demonstrated significant potential in software engineering tasks such as code generation, driving the development of dedicated code generation models. Existing large language models primarily focus on converting general natural language descriptions into general-purpose program code. However, mobile applications involve complex user interfaces and dynamic UI states, making this approach difficult to apply directly to mobile application scenarios. RAGDroid is specifically designed for mobile application GUI testing scenarios. It uses multimodal perception technology to understand interface elements and combines this with a dynamic exploration mechanism to obtain real-time application state feedback, thereby generating functional test cases that conform to actual interaction logic. Summary of the Invention
[0012] To address the aforementioned issues, this invention proposes a retrieval-enhanced mobile application functional test generation method (RAGDroid), which can automatically generate executable, high-quality functional test cases for the input mobile application and its specific functional requirements.
[0013] This invention is achieved through the following technical solution: a method for generating mobile application function tests based on retrieval enhancement; the method specifically includes the following steps: Step 1: Knowledge retrieval and fusion. Retrieve the test cases most relevant to the current functional requirements from the historical test cases in the functional test case database, and extract the domain knowledge for testing the corresponding functions to provide a reliable reference for test generation; Step 2, Context-Aware Test Generation: Based on the domain knowledge obtained in Step 1, and combined with the dynamic awareness of the target application's current graphical interface, generate executable test cases that conform to the actual context.
[0014] Furthermore, in step 1, knowledge retrieval and fusion are achieved through a semantic retrieval agent and a knowledge fusion agent; The semantic retrieval agent is based on a pre-built functional test case database. It performs semantic matching between user requirements and functional summaries to retrieve relevant test case sets. The knowledge fusion agent extracts domain knowledge from the search results and organizes them into structured knowledge documents, providing knowledge guidance for subsequent test generation.
[0015] Furthermore, the functional test case database is constructed through test case collection and functional summary generation; Collect valid test cases through existing public datasets and open-source projects; For each test case, a functional summary is generated based on a large language model, and a functional description is generated using a structured template to summarize the core functions being tested.
[0016] Furthermore, the structured template for generating functional summaries based on a large language model includes four components: task definition, input objects, output template, and acceptance requirements. The task definition clearly defines the core task that the large language model needs to complete, namely, summarizing the functional test cases into a single sentence. The input object provides the functional test cases to be summarized and their corresponding application category information. To enable the large language model to fully understand the test cases, JSON format is used for import, and the test cases are decomposed into events and assertions, and presented in a semi-structured format. Among them, events include component identifiers, operation types and optional input parameters; assertions include component identifiers and verification conditions. The output template is based on a few-shot learning mechanism and demonstrates the mapping relationship between test cases and functional summaries; The acceptance requirements specify the requirements that the output of the large language model must meet in order to improve the accuracy of summary generation and reduce the illusion phenomenon of the large language model.
[0017] Furthermore, in step 2, context-aware test generation is achieved through a perceptual interactive agent and a decision-generating agent; The perceptual interactive agent is responsible for dynamically acquiring the interface state information of the target application, providing environmental context for the decision-generating agent, and transforming abstract instructions into specific interactive operations. The decision-generating agent integrates real-time interface information with the domain knowledge obtained in step 1 to generate an operation strategy that adapts to the current application state.
[0018] Furthermore, the perceptual interactive intelligent agent includes an interface perception module, an exploration execution module, and a use case synthesis module; The interface perception module generates screenshots and structured natural language descriptions by parsing the UI hierarchy. The exploration execution module transforms the test instructions output by the decision-generating agent into specific GUI interactive actions; The test case synthesis module integrates interactive events and verification assertions into executable test cases.
[0019] Furthermore, the decision-generating intelligent agent includes a step selection module, an instruction generation module, and a completion judgment module; The step selection module adopts a sliding window mechanism to select the applicable steps based on the requirement description, test steps, and interface status. The instruction generation module generates specific operation instructions for event-type steps or assertion-type steps. The completion judgment module evaluates the completion status of the steps in real time through an active query mechanism.
[0020] A mobile application function test generation system based on retrieval enhancement, characterized in that; The system includes a knowledge retrieval and fusion subsystem and a context-aware test generation subsystem; The knowledge retrieval and fusion subsystem retrieves the test cases most relevant to the current functional requirements from the historical test cases in the functional test case database, and extracts the domain knowledge for detecting the corresponding functions, providing a reliable reference for test generation; The context-aware test generation subsystem generates executable test cases that conform to the actual context, based on the domain knowledge obtained by the knowledge retrieval and fusion subsystem and combined with the dynamic perception of the target application's current graphical interface.
[0021] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0022] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0023] Beneficial effects of the invention This invention proposes a retrieval-enhanced mobile application functional test generation method (RAGDroid). It automatically generates executable, high-quality functional test cases based on the input mobile application (such as a to-do list app, browser, etc.) and its specific functional requirements (such as adding and deleting to-do items, verifying search functionality, etc.). This solves the problems of difficult test case reuse, poor adaptability, and the need for manual writing in traditional mobile application testing, while also overcoming the shortcomings of existing automated testing solutions, such as the lack of assertion generation and low success rate.
[0024] RAGDroid specifically addresses the shortcomings of existing automated testing solutions, such as difficulty in test case reuse, poor interface adaptation, and inability to generate assertions. Existing solutions rely on textual information and lack historical knowledge reuse. RAGDroid combines multimodal interface information that integrates visual and textual elements, and directly reuses the core logic of historical test cases through knowledge retrieval and fusion, reducing redundant operations. Existing solutions only generate operation sequences and cannot verify whether the function is effective. RAGDroid extracts domain knowledge to generate key assertions, ensuring test effectiveness and enhancing the practical application value of test cases. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the overall process of the RAGDroid of the present invention; Detailed Implementation The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] Unless otherwise specified, the experimental methods used in the following examples are conventional methods. Unless otherwise specified, the materials, reagents, methods, and instruments used are all conventional materials, reagents, methods, and instruments in the art, and can be obtained commercially by those skilled in the art.
[0027] like Figure 1 As shown, to address the problems existing in the prior art, this invention proposes a method for generating mobile application function tests based on retrieval enhancement: the method specifically includes the following steps: Step 1: Knowledge retrieval and fusion. Retrieve test cases that are most relevant to the semantics of the current functional requirements from historical test cases, and extract the domain knowledge (general test logic) for testing the corresponding functions to provide a reliable reference for test generation; Based on the target application and its functions to be verified, the knowledge retrieval and fusion phase aims to retrieve functionally similar instances from existing real-world use cases and extract expert-level domain knowledge from them. However, the key challenge is how to accurately match the developer's functional testing requirements from a massive number of test cases and further extract reusable domain knowledge from the matching results. To this end, two core intelligent agents are introduced: a semantic retrieval agent and a knowledge fusion agent (such as...). Figure 1 (As shown).
[0028] Specifically, the semantic retrieval agent, based on a pre-built functional test case database, semantically matches user requirements with functional summaries to retrieve a relevant set of test cases. Subsequently, the knowledge fusion agent extracts domain knowledge from the retrieval results and organizes them into structured knowledge documents, providing reliable knowledge guidance for subsequent test generation.
[0029] 1.1 Semantic Retrieval Agent: In real-world software development environments, a large number of functional test cases exist, containing specific logic and domain knowledge for verifying particular application functions, and possess significant reference value. However, these test cases are typically scattered across different sources, and their effective utilization depends on a systematic process of collection, organization, and retrieval. The core challenge lies in how to build a high-quality retrieval database and achieve accurate retrieval of relevant test cases.
[0030] Database Construction: This section will introduce the process of collecting test cases and the method of generating functional summaries.
[0031] Test case collection: To build a functional test case database, test cases are systematically collected through the following two channels.
[0032] (1) Existing Data: There are two test case datasets in the field of mobile application testing: the Lin dataset and the FrUITeR dataset. Test cases were collected from them, resulting in 85 valid test cases, covering six common application scenarios such as news and shopping.
[0033] (2) Open source projects: To further enhance the diversity and coverage of data, this invention also systematically collected test cases from F-Droid, the world's largest open source application store. For eight common categories, including navigation, motion, and system, projects containing functional test cases were selected from the top 30 applications in each category, resulting in a total of 199 test cases.
[0034] Functional Summary Generation: To facilitate subsequent semantic retrieval, this invention generates a concise functional summary for each test case, summarizing its core detected function. Considering the powerful understanding and summarizing capabilities of large language models, an automated summary generation method based on large language models is designed to replace traditional manual or rule-based methods. This method possesses good scalability, facilitating future database expansion, while ensuring consistency in summary quality and semantic accuracy.
[0035] To guide large language models in accurately understanding and performing summarization tasks, a clear structured template was designed, comprising the following four parts: (1) Task definition: This section clarifies the core task that the large language model needs to complete, namely, summarizing the functional test cases into a single sentence.
[0036] (2) Input Object: This section provides the functional test cases to be summarized and their corresponding application category information. To ensure the large language model fully understands the test cases, RAGDroid imports them in JSON format and decomposes them into a series of events and assertions, presented in a semi-structured format. Events include component identifiers, operation types, and optional input parameters; assertions include component identifiers and validation conditions. Each component contains multiple attributes; to accurately and concisely represent components, RAGDroid uses only three key attributes—text, resource-id, and content-desc—to characterize components.
[0037] (3) Output Templates: Based on the significant advantage of few-shot learning over zero-shot learning, this invention employs a few-shot learning mechanism and provides two complete examples in the prompt template. These examples clearly demonstrate the mapping relationship between test cases and functional summaries, helping large language models accurately understand the output format and specific tasks.
[0038] (4) Acceptance Requirements: This section mainly specifies the requirements that the output of the large language model must meet to improve the accuracy of summary generation and reduce the illusion phenomenon of the large language model. Specifically, these include: First, the output should be concise, containing at most a subject-verb-object structure; second, it should generate natural language descriptions rather than code; third, it should focus on the main operations of the test cases and ignore secondary content. These requirements together ensure the accuracy and readability of the generated content. The final database covers 13 common categories and 71 applications, including 294 functional test cases and their corresponding summaries. To support efficient semantic retrieval, RAGDroid adopts a structured database storage format: the test case category is used as the first-level index key (Key1), the embedding vector of the summary is used as the second-level index key (Key2), and the original test case is used as the stored value (Value), thus constructing a test case database that supports multi-dimensional retrieval. This design effectively supports accurate semantic retrieval of test cases by combining a dual mechanism of category filtering and semantic matching.
[0039] Test Case Retrieval: For user-inputted functional test requirements, RAGDroid first encodes them as embedding vectors, then performs vector similarity retrieval in the test case database. By calculating the cosine similarity between the vectors and the test case summary vectors, RAGDroid selects the top 10 results with the highest similarity and belonging to the same category; the corresponding test cases are the retrieved relevant test cases. The valuable domain knowledge contained in these test cases will serve as an important reference for the subsequent test generation process, providing a knowledge foundation for functional verification.
[0040] 1.2 Knowledge-integrated intelligent agent: To achieve effective reuse of domain knowledge, knowledge fusion agents are dedicated to extracting common test logic from multiple related test cases. Taking user registration as an example, although different applications differ in their specific implementations (such as using different verification methods like email and password or username and phone number), their core test logic follows the same pattern: inputting standardized information on the registration interface, performing the registration operation, and verifying the result status. The core objective of knowledge fusion agents is to fuse application-independent common test logic from multiple related test cases, shielding specific implementation details, thereby providing reusable domain knowledge for subsequent test generation and achieving a guidance effect similar to that of a test expert.
[0041] Knowledge Fusion: To achieve this goal, the agent provides a structured processing framework based on a large language model. This framework comprises four key components. In the "Task Definition," it is explicitly required that the model fuse general test knowledge based on multiple relevant use cases and target requirements. The "Input Objects" provide relevant test cases acquired by the semantic retrieval agent. The "Output Template" demonstrates the abstraction and fusion process of test knowledge and the output format through complete examples. The "Acceptance Requirements" set the following constraints: First, the number of test steps must remain within a reasonable range; second, the specified format specifications must be strictly followed, with events using the format "Event:[Action] a widget [Widget]with [Value]" and assertions using the format "Assertion: Identifyawidget [Widget][Condition]"; third, the output should directly present the test logic without additional explanations or code instructions.
[0042] Hallucination Mitigation: To address the hallucination problem in large language models, RAGDroid has established an automated detection and feedback mechanism. This mechanism checks whether the generated content conforms to format specifications, required number of steps, and content purity standards through preset rules. When unqualified output is detected, the system automatically provides feedback and requests regeneration until a test logic description that meets all specifications is obtained. This closed-loop verification process effectively ensures the reliability of the knowledge fusion process and the quality of the output.
[0043] Step 2, Context-Aware Test Generation: Based on the domain knowledge obtained in Step 1, and combined with the dynamic awareness of the target application's current graphical interface, generate executable test cases that conform to the actual context.
[0044] While reference test cases provide a logical framework and domain knowledge for functional verification, the specific implementation details of similar functions differ significantly across applications, making it impossible to directly apply the logical framework to the target application. Effectively adapting test logic to a specific application and generating concrete events and assertions remains a significant challenge. To address this issue, this invention designs two collaborative agents: a perception and interaction agent and a decision-generating agent (such as...). Figure 1 (As shown).
[0045] Specifically, the perception-interaction agent is responsible for dynamically acquiring the interface state information of the target application and providing environmental context for the decision-generating agent, while transforming abstract instructions into concrete interactive operations. The decision-generating agent then integrates real-time interface information with the domain knowledge obtained in the first phase to generate an operational strategy adapted to the current application state. Through the alternating execution and closed-loop feedback of the two agents, the system achieves an effective transformation from abstract test logic to concrete test cases. The two agents form a dynamic test generation closed loop through alternating execution and information interaction.
[0046] 2.1 Perceptual Interactive Intelligent Agent The core task of this intelligent agent is to explore the target application by dynamically acquiring multimodal information about the interface (including visual information from screenshots and textual information about the interface structure), and then executing specific operations based on the decision-making process that generates the agent's instruction sequence. The system will continue to run until it receives a "task completed" signal, automatically recording all interaction events and verification assertions during this process, and finally integrating them into a complete functional test case. The workflow of this intelligent agent includes the following three key components.
[0047] Interface Awareness: The perceptive interaction agent captures the visual and interactive elements of the current interface in real time by parsing the UI hierarchy of the target application. The implementation involves two key steps: first, generating a screenshot of the current interface to preserve complete visual information; second, converting the interface content into a structured natural language description. During this description process, the system extracts three core semantic attributes—text, content-desc, and resource-id—for each UI component and lists the operation types supported by the component.
[0048] To ensure logical flow in the description, RAGDroid organizes all components in the interface in a spatial order from top left to bottom right. This arrangement conforms to the user's natural browsing habits and forms a clear state description process.
[0049] Ultimately, the screenshots and natural language descriptions of the interface structure will be used as multimodal inputs and passed to the decision-generating agent to provide it with sufficient environmental context support. Exploration and Execution: Based on the decision-making process, the system generates test instructions (such as clicking on a specific component) from the output of the intelligent agent. This component is responsible for translating abstract test instructions into concrete GUI interaction actions. By calling the underlying API of the mobile testing framework, the system can accurately execute predefined operations such as clicks, inputs, and swipes, and monitor the application's state changes in real time for assertion verification. Test case synthesis: After the test sequence is completed, this component will structurally integrate the interactive events generated during the entire exploration process with the corresponding verification assertions in the order of execution, and finally generate executable functional test cases that conform to the test framework specifications, thus completing the transformation process from dynamic interactive behavior to standardized test cases. 2.2 Decision-Generating Intelligent Agent As the core coordination module of the RAGDroid system, the decision-generating agent bears the key responsibility of test strategy formulation. Based on the current interface state information, the requirement description of the test cases to be generated, and the guiding test steps generated in the knowledge retrieval and fusion phase, this agent makes dynamic decisions and generates corresponding operation instructions or assertions, thereby driving the perceptual interaction agent to execute specific tests. In the actual decision-making process, the system faces three core challenges.
[0050] First, since the guiding test steps may come from the integration of common logic from multiple applications (such as removing a list, some applications require selecting the list and clicking the delete button; others require swiping to delete), only some steps may be applicable to the current target application. Therefore, precise step selection and adaptation are required on the target application. Secondly, after determining the applicable steps, it is necessary to accurately match them with the specific UI components in the current interface to generate executable instruction descriptions, which will facilitate the generation of subsequent events and assertions. Finally, due to the inherent limitations and illusion problem in the task termination judgment of large language models, it is difficult for them to actively realize whether the task has been completed, and thus they explore in an disorderly manner after the task is completed. Therefore, it is necessary to establish an effective completion judgment mechanism to avoid generating redundant operations. To address the aforementioned challenges, the decision-generating agent is designed with three core modules that work together: step selection, instruction generation, and completion judgment.
[0051] Step Selection: In this module, RAGDroid provides three input information to the large language model: the requirement description of the test cases to be generated, the guiding test steps generated in the knowledge retrieval and fusion stage, and the interface state information captured by the perceptual interactive agent (including screenshots and interface structure).
[0052] To improve decision-making accuracy, RAGDroid employs a sliding window mechanism to manage the sequence of test steps. The large language model only needs to focus on `Stepnum` test steps within the window at a time. This design allows the LLM to centrally analyze a finite candidate set and accurately evaluate the applicability of each step based on the current interface state. The model needs to reason according to the order of the steps in the window, selecting the specific test step that best matches the current context. If no applicable step is found in the window, a specific flag "(-1)" is returned, triggering the sliding window mechanism to update the set of steps to be evaluated.
[0053] Instruction Generation: This module receives three inputs: a description of the requirement to be verified, a single test step determined by the step selection module, and the current interface information provided by the perceptual interaction agent. Based on these inputs, the large language model needs to generate specific operation instructions to execute the current test step and pass the instructions to the perceptual interaction agent for execution. Simultaneously, RAGDroid records completed test steps and their corresponding instructions to avoid repetitive operations. For test steps of different natures, RAGDroid employs a differentiated processing mechanism: Event-based steps: The large language model returns the specified component ID and operation ID. This combined information will be passed to the perceptual interaction agent for execution and finally integrated into the generated test cases. Assertion-based steps: These steps involve a target component and verification conditions. GUI testing primarily involves two types of conditions. The first verifies the existence of a component in the current interface. The second verifies the disappearance of a component that appeared in a previous interface. For existence verification, RAGDroid inputs the current interface state and the test steps into a large language model, which returns the corresponding component ID. For disappearance verification, since the target component is not present in the current interface, RAGDroid identifies the corresponding component from historical interfaces and returns its ID through a state backtracking mechanism. After identifying the component, RAGDroid generates the corresponding assertion based on the component ID and the conditions in the test steps, and transmits this information to the perceptual interaction agent for verification. Completion Judgment: To address the inherent limitations and illusion problems in task termination judgments of large language models, RAGDroid designed an active query mechanism. This mechanism decomposes the overall test task into an ordered sequence of test steps and performs real-time status evaluation during the execution of each test step. Specifically, once the large language model generates operation instructions, RAGDroid immediately initiates the completion judgment process. At this point, the model infers based on three key pieces of information: the description of the current test step, the sequence of executed instructions, and the latest interface state. The model outputs a binary judgment result ("Yes" indicates the step is complete; "No" indicates incomplete). If the judgment is complete, RAGDroid proceeds to the selection stage of the next test step; if the judgment is incomplete, it continues to generate subsequent instructions for the current step. To avoid getting stuck in infinite loops on certain complex steps, RAGDroid sets a maximum number of attempts limit. When consecutive attempts on the same test step reach a preset threshold, even if the model still judges it as incomplete, RAGDroid will automatically skip that step and proceed to process subsequent test steps. This design ensures that each step is fully explored while maintaining the overall efficiency of the test process. The advantages of this proactive query mechanism are: on the one hand, it ensures the integrity of the test logic through real-time state evaluation; on the other hand, it effectively handles complex test scenarios requiring multiple steps through progressive exploration, ensuring execution efficiency.
[0054] A mobile application functionality test generation system based on retrieval enhancement; The system includes a knowledge retrieval and fusion subsystem and a context-aware test generation subsystem; The knowledge retrieval and fusion subsystem retrieves the test cases most relevant to the current functional requirements from the historical test cases in the functional test case database, and extracts the domain knowledge for detecting the corresponding functions, providing a reliable reference for test generation; The context-aware test generation subsystem generates executable test cases that conform to the actual context, based on the domain knowledge obtained by the knowledge retrieval and fusion subsystem and combined with the dynamic perception of the target application's current graphical interface.
[0055] Example: Regarding parameter configuration, two hyperparameters of RAGDroid were optimized and determined through systematic pre-experiments: for the sliding window size $Step_{num}$ and the number of similar test cases retrieved $Top_{sim}$, this invention conducted verification experiments based on 20% of the test cases in the candidate set {1,2,3}. The results showed that RAGDroid performed best when $Step_{num}=2$ and $Top_{sim}=3$, and this configuration was finally adopted in the final experiment.
[0056] It is important to note that, given RAGDroid's inclusion of a database retrieval module, this invention employs a rigorous evaluation process: when generating test cases for each target application's corresponding function, RAGDroid pre-removes all test cases related to that target application from the retrieval database. This measure ensures that RAGDroid obtains test cases through generation, rather than through a possible retrieval method, thus accurately reflecting its functional test generation capabilities.
[0057] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0058] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0059] The memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory of the methods described in this invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0060] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means such as coaxial cable, optical fiber, digital subscriber line, DSL, or wireless means such as infrared, wireless, microwave, etc. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium such as a floppy disk, hard disk, magnetic tape; an optical medium such as a high-density digital video disc, DVD; or a semiconductor medium such as a solid-state disk, SSD, etc.
[0061] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0062] It should be noted that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied as execution by a hardware decoding processor, or as execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above methods.
[0063] The above provides a detailed description of the mobile application function test generation method based on retrieval enhancement proposed in this invention, and elucidates the principles and implementation methods of this invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. A method for generating mobile application functional tests based on retrieval enhancement, characterized in that: The method specifically includes the following steps: Step 1: Knowledge retrieval and fusion. Retrieve the test cases most relevant to the current functional requirements from the historical test cases in the functional test case database, and extract the domain knowledge for testing the corresponding functions to provide a reliable reference for test generation. Step 2, Context-Aware Test Generation: Based on the domain knowledge obtained in Step 1, and combined with the dynamic awareness of the target application's current graphical interface, generate executable test cases that conform to the actual context.
2. The method according to claim 1, characterized in that: In step 1, knowledge retrieval and fusion are achieved through a semantic retrieval agent and a knowledge fusion agent; The semantic retrieval agent is based on a pre-built functional test case database. It performs semantic matching between user requirements and functional summaries to retrieve relevant test case sets. The knowledge fusion agent extracts domain knowledge from the search results and organizes them into structured knowledge documents, providing knowledge guidance for subsequent test generation.
3. The method according to claim 2, characterized in that: The functional test case database is constructed through test case collection and functional summary generation; Collect valid test cases through existing public datasets and open-source projects; For each test case, a functional summary is generated based on a large language model, and a functional description is generated using a structured template to summarize the core functions being tested.
4. The method according to claim 3, characterized in that: The structured template for generating functional summaries based on a large language model includes four components: task definition, input objects, output template, and acceptance requirements. The task definition clearly defines the core task that the large language model needs to complete, namely, summarizing the functional test cases into a single sentence. The input object provides the functional test cases to be summarized and their corresponding application category information. To enable the large language model to fully understand the test cases, JSON format is used for import, and the test cases are decomposed into events and assertions, presented in a semi-structured format. Events include component identifiers, operation types, and optional input parameters; assertions include component identifiers and verification conditions. The output template is based on a few-shot learning mechanism and demonstrates the mapping relationship between test cases and functional summaries; The acceptance requirements specify the requirements that the output of the large language model must meet in order to improve the accuracy of summary generation and reduce the illusion phenomenon of the large language model.
5. The method according to claim 4, characterized in that: In step 2, context-aware test generation is achieved through a perceptual interactive agent and a decision-generating agent; The perceptual interactive agent is responsible for dynamically acquiring the interface state information of the target application, providing environmental context for the decision-generating agent, and transforming abstract instructions into specific interactive operations. The decision-generating agent integrates real-time interface information with the domain knowledge obtained in step 1 to generate an operation strategy that adapts to the current application state.
6. The method according to claim 5, characterized in that: The perceptual interactive intelligent agent includes an interface perception module, an exploration execution module, and a use case synthesis module; The interface perception module generates screenshots and structured natural language descriptions by parsing the UI hierarchy. The exploration execution module transforms the test instructions output by the decision-generating agent into specific GUI interactive actions; The test case synthesis module integrates interactive events and verification assertions into executable test cases.
7. The method according to claim 6, characterized in that: The decision-generating intelligent agent includes a step selection module, an instruction generation module, and a completion judgment module; The step selection module adopts a sliding window mechanism to select the applicable steps based on the requirement description, test steps, and interface status. The instruction generation module generates specific operation instructions for event-type steps or assertion-type steps. The completion judgment module evaluates the completion status of the steps in real time through an active query mechanism.
8. A mobile application function test generation system based on retrieval enhancement, characterized in that: The system is based on the mobile application function test generation method based on retrieval enhancement as described in any one of claims 1 to 7; The system includes a knowledge retrieval and fusion subsystem and a context-aware test generation subsystem; The knowledge retrieval and fusion subsystem retrieves the test cases most relevant to the current functional requirements from the historical test cases in the functional test case database, and extracts the domain knowledge for detecting the corresponding functions, providing a reliable reference for test generation; The context-aware test generation subsystem generates executable test cases that conform to the actual context, based on the domain knowledge obtained by the knowledge retrieval and fusion subsystem and combined with the dynamic perception of the target application's current graphical interface.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 7.