Test case generation method and device, equipment and medium
By constructing a target knowledge graph and optimizing strategy parameters through an intelligent agent system, the inefficiency of traditional testing methods is solved, enabling adaptive and self-evolving test case generation, thus improving testing quality and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN YOUIBOT ROBOTICS CO LTD
- Filing Date
- 2025-11-25
- Publication Date
- 2026-04-10
AI Technical Summary
Traditional automated testing methods cannot effectively cope with changing testing requirements and complex system architectures, resulting in low testing efficiency and an inability to achieve continuous learning and optimization.
An intelligent agent system is adopted, including a requirements analysis agent, a test case generation agent, an execution verification agent, and an evolutionary learning agent. By constructing a target knowledge graph, generating initial test cases, and optimizing the policy parameters of the intelligent agent system based on test results, adaptive and self-evolving test case generation is achieved.
It enables efficient test case generation with low human intervention, continuously improving test quality and efficiency, reducing human error, and ensuring the accuracy and comprehensiveness of test objectives.
Smart Images

Figure CN121833477A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and medium for generating test cases. Background Technology
[0002] As software systems become increasingly complex, traditional automated testing methods are no longer sufficient to effectively address changing requirements and complex system architectures. Traditional testing methods often rely on static test case generation strategies, which suffer from low efficiency, insufficient coverage, and an inability to adapt to dynamic changes. Especially in complex application scenarios, traditional, single-function test case generation systems cannot efficiently handle large amounts of test data and diverse testing needs.
[0003] While rule-based automated testing tools exist in related technologies, they lack the ability to dynamically adapt to changes in system requirements, making it difficult to generate efficient and comprehensive test cases. Furthermore, most testing systems cannot effectively collaborate in multi-tasking and complex testing scenarios, resulting in low testing efficiency and hindering continuous learning and optimization, severely impacting test quality and efficiency.
[0004] Therefore, it is necessary to propose a test case generation method that can respond to changes in test requirements in real time, automatically adjust test strategies, and improve test quality and efficiency. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and medium for generating test cases to solve the technical problem in related technologies that cannot achieve real-time response to changes in test requirements and automatic adjustment of test strategies, resulting in low test quality and efficiency.
[0006] Firstly, a method for generating test cases is provided, applied to an intelligent agent system, the intelligent agent system including a communication connection requirement analysis intelligent agent, a test case generation intelligent agent, an execution verification intelligent agent, and an evolutionary learning intelligent agent, the method comprising: The demand analysis agent receives software testing requirements, extracts the test points of the software testing requirements, and constructs a target knowledge graph based on the test points. The test case generation agent generates initial test cases based on the test target knowledge graph. The initial test cases are executed by the execution verification agent to obtain test results; wherein, the test results include a validity determination of the initial test cases and the basis for such determination; In response to the test result determining that the initial test case is invalid, the evolutionary learning agent optimizes the policy parameters of each agent in the agent system based on the determination criteria and generates new test cases.
[0007] Secondly, a test case generation device is provided, comprising: The receiving module is used to receive software testing requirements through the requirement analysis agent, extract the test points of the software testing requirements, and construct a target knowledge graph based on the test points; The generation module is used to generate initial test cases based on the test target knowledge graph through the test case generation agent; An execution module is used to execute the initial test cases through the execution verification agent to obtain test results; wherein, the test results include a validity determination of the initial test cases and the basis for the determination; An optimization module is used to respond to the test result determining that the initial test case is an invalid test case, and to optimize the policy parameters of each agent in the agent system based on the determination criteria by the evolutionary learning agent, and generate new test cases.
[0008] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described test case generation method.
[0009] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described test case generation method.
[0010] The solution implemented by the above-mentioned test case generation method, apparatus, computer equipment, and storage medium includes the following steps: receiving software test requirements through a requirements analysis agent, extracting test points from the software test requirements, and constructing a target knowledge graph based on the test points; generating initial test cases based on the test target knowledge graph through a test case generation agent; executing the initial test cases through an execution verification agent to obtain test results; wherein, the test results include a validity judgment of the initial test cases and the judgment criteria; in response to the test results determining that the initial test cases are invalid test cases, optimizing the policy parameters of each agent in the agent system based on the judgment criteria through an evolutionary learning agent, and generating new test cases. In this invention, by automatically parsing software test requirements and extracting test points through a requirements analysis agent, the risk of omissions caused by human misunderstanding of requirements can be effectively reduced, ensuring the accuracy and completeness of the test target knowledge graph construction. Furthermore, the test case generation agent generates initial test cases based on the target knowledge graph, enabling the initial test cases to closely revolve around functional points, constraints, and target outputs, improving the relevance and comprehensiveness of the generated initial test cases. During the test execution phase, the initial test cases are executed by a verification agent, generating test results including validity judgments and their criteria. This enables the system to accurately identify invalid test cases and their failure modes. Furthermore, an evolutionary learning agent optimizes the policy parameters of each agent in the system based on the judgment criteria, achieving adaptive adjustments to test case generation, requirement parsing, and verification strategies, thus constructing a continuously learning, self-evolving closed loop. This application not only automatically generates new, higher-quality test cases but also continuously improves the efficiency and coverage of the entire testing process through multiple iterations, thereby realizing a highly efficient, low-manual-dependency, and continuously optimizable test case generation method. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of a test case generation method in one embodiment of the present invention; Figure 2 yes Figure 1 A schematic diagram of a specific implementation method for step S10; Figure 3 This is a schematic diagram of a scenario illustrating a test case generation method in one embodiment of the present invention; Figure 4This is a schematic diagram of a test case generation device in one embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 6 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0013] 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, not all, of the embodiments of the present invention. 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.
[0014] Please see Figure 1 As shown, Figure 1 This is a schematic diagram of a test case generation method in one embodiment of the present invention. The test case generation method is applied to an intelligent agent system, which includes a communication connection requirement analysis intelligent agent, a test case generation intelligent agent, an execution verification intelligent agent, and an evolutionary learning intelligent agent. The method includes the following steps: S10: The requirement analysis agent receives software testing requirements, extracts the test points of the software testing requirements, and constructs a target knowledge graph based on the test points.
[0015] It should be noted that the software testing requirements are test specification documents input by testers or automatically generated by the system, which describe the functional behavior, business logic and important constraints of the software under test; the test points are key verification targets extracted from the software testing requirements, which are used to indicate the specific functions or constraints that need to be covered by the subsequent test cases.
[0016] Furthermore, the requirements analysis agent is an intelligent component used to automatically parse software test requirements and generate structured test knowledge. Its core function is to perform semantic analysis, entity extraction, and intent recognition on the input test requirement text through a natural language processing model, thereby transforming unstructured human descriptions into machine semantic information that the system can understand and reason about.
[0017] For example, a requirements analysis agent can parse test requirement text using a natural language processing model to obtain structured requirement information. This structured requirement information includes functional descriptions, input / output requirements, business boundary conditions, and exception handling logic. Furthermore, corresponding test points can be extracted based on this structured requirement information, and a target knowledge graph can be constructed based on the pre- and post-relationships, dependencies, and logical connections between these test points. This target knowledge graph represents the test point nodes and the relationships between them in a graph structure, used for visual modeling of test requirements and providing a knowledge basis for subsequent test case generation.
[0018] Among them, such as Figure 2 As shown, in step S10, the process of receiving software testing requirements through the requirement analysis agent, extracting the test points of the software testing requirements, and constructing a target knowledge graph based on the test points includes the following steps: S11: The requirement analysis agent parses the software testing requirements based on a natural language processing model to obtain structured requirement information.
[0019] S12: The test points are extracted from the structured requirement information by the requirement analysis agent.
[0020] The test points include software function points, constraints, and target outputs.
[0021] S13: The demand analysis agent constructs a target knowledge graph, including test objectives and related relationships, based on the test points.
[0022] For example, in step S11, the test requirements can be analyzed at the lexical, syntactic, and semantic levels using a natural language processing model. Functional description statements, constraint statements, and target output statements can be identified from the original natural language description, and this information can be transformed into structured requirement information. This structured requirement information can include functional entities, business logic entities, input / output entities, and related descriptive attributes, enabling subsequent processing stages to move beyond reliance on textual expression and achieve a unified semantic expression of the requirement content. Thus, the requirement analysis agent can convert unstructured text content into a computable and reasonable standardized data structure, laying the foundation for accurately extracting test points.
[0023] Furthermore, in steps S12 and S13, the requirement analysis agent can extract test points and construct the target knowledge graph based on structured requirement information. In step S12, test points are extracted from the structured requirement information using algorithms such as rule matching, semantic classification, and entity relationship recognition. These test points include one or more of the following elements: software function points, business constraints, and expected output results. Subsequently, in step S13, the requirement analysis agent identifies the pre-existing dependencies, logical relationships, and business link relationships between the extracted test points, and constructs the target knowledge graph using nodes and edges. The constructed knowledge graph can express the semantic relationships of the test targets in a visual graph structure, guiding the subsequent test case generation process and making test generation more systematic, logical, and traceable.
[0024] S20: The agent generates initial test cases based on the test target knowledge graph through the test case generation.
[0025] In some embodiments, the step of generating initial test cases based on the test target knowledge graph by the test case generating agent includes: receiving the test target knowledge graph by the test case generating agent, and performing task decomposition on the test targets in the test target knowledge graph to obtain decomposed test tasks; and generating corresponding initial test cases based on the decomposed test tasks by the test case generating agent using a reinforcement learning algorithm.
[0026] It should be noted that the test case generation agent is the core component of the system responsible for transforming the test target knowledge graph into executable test cases. The test target knowledge graph is a graph structure data constructed in step S10 that describes test points and their relationships, indicating the functional objectives, constraints, and logical links that the generated test cases must cover. The nodes in the test target knowledge graph correspond to different test objectives, and the relationships between nodes represent the dependencies or triggering order between test points, providing a structural basis for further decomposition of the test task.
[0027] For example, a test case generation agent can receive a test target knowledge graph and, based on preset task decomposition rules, parse the test targets in the graph layer by layer to obtain decomposed test tasks. These test tasks decompose complex test targets into executable sub-task structures, guiding the test case generation agent in strategy selection. Furthermore, the preset task decomposition rules can include decomposition strategies for different types of test points, such as functional objectives, constraints, and business links, used to progressively break down complex or highly abstract test targets in the graph into executable test tasks. For instance, a test target with multiple preconditions can be decomposed into several sub-tasks arranged in an execution sequence based on the order of node dependencies; a test point with multiple constraints can be classified and decomposed according to constraint type (such as input boundary constraints, path constraints, and business rule constraints); and a test target with multi-branch business processes can be decomposed into multiple parallel test paths based on the branching rules in the graph.
[0028] Furthermore, initial test cases can be generated based on the decomposed test tasks using a reinforcement learning algorithm. The reinforcement learning algorithm determines the optimal test strategy by comprehensively calculating historical test data, strategy benefits, and task characteristics, thereby generating initial test cases that can cover the decomposed tasks.
[0029] S30: The initial test case is executed by the execution verification agent to obtain the test results.
[0030] The test results include a determination of the validity of the initial test cases and the basis for such determination.
[0031] In some embodiments, the step of executing the initial test case through the execution verification agent to obtain test results includes: loading and running the initial test case in a preset test environment through the execution verification agent; during the operation of the initial test case, monitoring the running status of the initial test case through the execution verification agent to obtain running status information, wherein the running status information includes performance indicators and anomaly information; comparing the running status information with preset expected results through the execution verification agent to generate a validity judgment and judgment criteria for the initial test case; and determining the test result of the corresponding initial test case based on the validity judgment and the judgment criteria.
[0032] It should be noted that the execution verification agent is the core component of the system responsible for test execution and result verification. This agent loads and runs initial test cases in a preset test environment, monitors the system's running status in real time, and collects running status data, including performance indicators and anomaly information. The test results are the data generated by the execution verification agent after detecting and analyzing the actual performance of the software system during the execution of the initial test cases. These results characterize whether the test cases can correctly verify the target function. The test results include not only a determination of the validity of the initial test cases but also the basis for supporting that determination.
[0033] For example, the initial test case can be loaded and run in a preset test environment by executing a verification agent. The preset test environment can be a real runtime environment or a simulation test environment. During the execution of the initial test case, the verification agent can monitor the running status of the test case in real time to obtain running status information. This running status information may include performance indicators such as response time and resource usage, as well as abnormal information such as functional anomalies and system errors. Furthermore, the verification agent can compare the running status information with preset expected results to determine whether the test case's behavior meets the expected logic, and generate a corresponding validity judgment and judgment criteria based on the comparison results. The validity judgment indicates whether the initial test case can successfully verify the target function, and the judgment criteria record the specific running conditions that led to the judgment result. Finally, the verification agent determines the validity judgment and the judgment criteria as the test result of the corresponding initial test case for use in subsequent steps. S40: In response to the test result determining that the initial test case is an invalid test case, the evolutionary learning agent optimizes the policy parameters of each agent in the agent system based on the determination criteria, and generates new test cases.
[0034] It should be noted that the evolutionary learning agent is the core component driving continuous system optimization, responsible for the self-evolution of the test case generation process. The invalid test cases are those determined by the execution verification agent in step S30 based on a comparison of the running status information with the preset expected results, which fail to cover the target function or trigger the actual business logic. The determination criteria are state characteristics used to characterize the reasons for invalidity, including exception logs, functional deviations, timeout information, and resource anomalies, etc., for subsequent learning and optimization.
[0035] For example, an evolutionary learning agent can receive validity judgments and corresponding judgment criteria from the execution verification agent, and analyze these judgment criteria based on a self-evolutionary learning mechanism to identify strategy defects that cause test cases to fail. For instance, by analyzing information such as anomaly types, path deviations, or constraint conflicts in the judgment criteria, deficiencies in the test point extraction strategy of the requirements analysis agent, the generation strategy of the test case generation agent, and the execution strategy of the execution verification agent can be identified.
[0036] Furthermore, the policy parameters of each agent can be optimized based on reinforcement learning algorithms or policy gradient adjustment methods, enabling them to more accurately match the target knowledge graph and improve test coverage during the next round of test case generation. Finally, the evolutionary learning agent generates new test cases based on the optimized policy parameters to replace invalid test cases and enters the next round of testing.
[0037] In some embodiments, the step of responding to the test result determining that the initial test case is an invalid test case, optimizing the policy parameters of each agent in the agent system based on the determination criteria by the evolutionary learning agent, and generating new test cases, includes: parsing the determination criteria by the evolutionary learning agent to obtain the root cause pattern that causes the initial test case to be invalid; using a multi-agent reinforcement learning algorithm based on the root cause pattern by the evolutionary learning agent to synchronously adjust the policy parameters of the requirement analysis agent, the test case generation agent, and the execution verification agent to obtain updated policy parameters; using a Monte Carlo tree search algorithm by the evolutionary learning agent to determine the optimal cooperative topology among each agent; and generating the new test cases by the agent system based on the updated policy parameters and the optimal cooperative topology.
[0038] For example, firstly, the evolutionary learning agent can perform deep analysis of the judgment criteria in the test results to identify and extract the root cause patterns that lead to the invalidity of the initial test cases. These root cause patterns include, but are not limited to, systemic defects such as: misunderstanding of requirements, incomplete test scenario coverage, missing boundary conditions, and mismatched verification standards. Next, based on the extracted root cause patterns, a multi-agent reinforcement learning algorithm is used to synchronously adjust the policy parameters of each agent in the system. Specifically: for the requirement analysis agent, the feature extraction weights in its natural language processing model are adjusted to optimize the accuracy of test point identification; for the test case generation agent, the reward function parameters in its reinforcement learning algorithm are adjusted to optimize the test case generation strategy; and for the execution verification agent, the sensitivity parameters of its verification rules are adjusted to optimize the anomaly detection and performance evaluation mechanisms.
[0039] Simultaneously, the evolutionary learning agents utilize the Monte Carlo tree search algorithm to explore and evaluate within a pre-defined agent collaboration topology space. This includes, for example, constructing a collaboration topology graph with each agent as a node, simulating task execution efficiency under different topologies, evaluating the performance of each topology scheme based on collaboration efficiency metrics, and ultimately selecting the topology with the highest collaboration efficiency as the optimal collaboration topology. Finally, the agent system restarts the test case generation process based on the updated policy parameters and the optimal collaboration topology. Through the optimized multi-agent collaboration mechanism, a new set of test cases with higher coverage and relevance is generated, achieving continuous improvement in testing capabilities and the system's self-evolution.
[0040] This embodiment establishes a complete analysis-optimization-generation closed loop, enabling the system to learn from failed test cases and continuously adjust the working strategies and collaboration methods of each agent, thereby significantly improving the quality of test cases and the efficiency of the testing process.
[0041] Based on the above embodiments, the step of determining the optimal cooperative topology among each agent using the Monte Carlo tree search algorithm through the evolutionary learning agent includes: constructing a cooperative topology graph with the agents as nodes through the evolutionary learning agent; determining the cooperative efficiency of each topology based on the cooperative topology graph in a preset topology space through the Monte Carlo tree search algorithm through the evolutionary learning agent; and determining the topology with the highest cooperative efficiency as the optimal cooperative topology through the evolutionary learning agent.
[0042] For example, a collaborative topology graph with each agent as a node can first be constructed using evolutionary learning agents. In this graph, nodes represent core system components such as requirement analysis agents, use case generation agents, and execution verification agents, while edges represent communication connections and task collaboration relationships between agents. The topology graph is constructed based on the current system's operating state and historical collaboration data to ensure accurate reflection of the actual collaboration patterns. Next, the evolutionary learning agents explore a pre-defined topology space using a Monte Carlo tree search algorithm. This topology space includes various possible agent connection methods, such as star topologies, mesh topologies, and hierarchical topologies.
[0043] Finally, the evolutionary learning agent sorts all evaluated topologies according to their collaborative efficiency and selects the topology with the highest collaborative efficiency as the optimal collaborative topology. This optimal topology will serve as the infrastructure for agent collaboration in the next round of test case generation, ensuring that each agent can work together in the most efficient way.
[0044] This embodiment, through systematic topology exploration and evaluation, can adaptively adjust the cooperative relationships between agents, effectively improving the overall efficiency and stability of the system when handling complex test tasks. The application of the Monte Carlo tree search algorithm enables the system to find near-optimal solutions in a large topology space, ensuring both optimization effectiveness and controlling computational complexity.
[0045] In other embodiments, the method further includes: storing the optimized strategy parameters and the validity information of the corresponding test cases into a test knowledge base through the evolutionary learning agent; retrieving historical similar requirements and corresponding historical test strategies from the test knowledge base when receiving new software test requirements through the requirement analysis agent; and analyzing the current test requirements based on the historical test strategies through the requirement analysis agent and generating target test cases.
[0046] For example, after completing each round of test case generation and optimization, the evolutionary learning agent systematically organizes the optimization results generated in this round, including: the optimized policy parameters of each agent, the validity judgment results of the corresponding test cases, and their detailed judgment criteria. This information is structured and stored in the test knowledge base, forming an accumulation of experience for the continuous evolution of the system.
[0047] When the system receives new software testing requirements, the requirements analysis agent automatically initiates a knowledge retrieval process. This agent first extracts features from the current testing requirements, and then retrieves historical similar requirements and their corresponding successful testing strategies from the testing knowledge base based on a semantic similarity algorithm. The retrieval process comprehensively considers multiple dimensions, including the functional characteristics, constraints, and target outputs of the requirements, to ensure the relevance and applicability of the retrieval results. Furthermore, based on the retrieved historical testing strategies, the requirements analysis agent uses a strategy fusion mechanism to analyze the current testing requirements. Specifically, this includes matching effective testing patterns from historical strategies with the features of the current requirements, adjusting the focus of knowledge graph construction, and optimizing the priority settings of testing objectives. Through this enhanced analysis based on historical experience, the system can directly generate more targeted target test cases, significantly improving the quality of initial test cases and reducing unnecessary test iterations.
[0048] This embodiment establishes a comprehensive knowledge accumulation and reuse mechanism, enabling the system to make full use of historical testing experience. This not only improves the efficiency of test case generation but also effectively enhances the overall intelligence level of the system through experience inheritance, giving it true learning and evolution capabilities.
[0049] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating a scenario of a test case generation method according to an embodiment of the present invention. For example... Figure 3As shown, the intelligent agent system includes a requirements analysis intelligent agent, a test case generation intelligent agent, an execution verification intelligent agent, and an evolutionary learning intelligent agent. The intelligent agent system's workflow consists of two closed-loop stages: forward test generation and backward evolutionary learning. During the forward test generation phase, test engineers submit software test plans and historical test data to the requirements analysis agent. The requirements analysis agent parses the software test requirements using a natural language processing model to obtain structured requirement information. It then extracts test points including software functionalities, constraints, and target outputs, and constructs a target knowledge graph containing test objectives and their relationships. The test case generation agent receives the test target knowledge graph, decomposes the test objectives into tasks, generates corresponding initial test cases based on reinforcement learning algorithms, and shares strategies through a communication mechanism to avoid duplication. The execution verification agent loads and runs the initial test cases in a preset test environment, monitors the running status to obtain running status information including performance indicators and anomaly information, compares it with preset expected results, generates a validity judgment and judgment criteria for the initial test cases, and forms the test results.
[0050] In the reverse evolutionary learning phase, in response to the test results determining the initial test cases as invalid, the evolutionary learning agent derives the root cause pattern from the decision criteria. A multi-agent reinforcement learning algorithm is then used to synchronously adjust the policy parameters of the requirements analysis agent, test case generation agent, and execution verification agent. A Monte Carlo tree search algorithm is used to determine the optimal collaborative topology among the agents. The system generates new test cases based on the updated policy parameters and the optimal collaborative topology. The evolutionary learning agent stores the optimized policy parameters and the validity information of the corresponding test cases in the test knowledge base. When new software testing requirements are received, the requirements analysis agent retrieves similar historical requirements and corresponding historical test strategies from the test knowledge base. Based on these historical test strategies, it analyzes the current test requirements, enabling continuous evolution of the system's testing capabilities.
[0051] As can be seen, in the above scheme, the automatic parsing of software testing requirements and extraction of test points by the requirements analysis agent can effectively reduce the risk of omissions caused by human misunderstanding of requirements, ensuring the accuracy and completeness of the test target knowledge graph construction. Secondly, the test case generation agent generates initial test cases based on the target knowledge graph, ensuring that the initial test cases closely revolve around functional points, constraints, and target outputs, improving the relevance and comprehensiveness of the generated initial test cases. During the test execution phase, the execution verification agent executes the initial test cases and generates test results including validity judgments and their criteria, enabling the system to accurately identify invalid test cases and their failure modes. Furthermore, the evolutionary learning agent optimizes the strategy parameters of each agent in the system based on the judgment criteria, achieving adaptive adjustment of test case generation, requirements parsing, and verification strategies, thereby constructing a continuous learning self-evolutionary closed loop. This application not only automatically generates new, higher-quality test cases but also continuously improves the efficiency and coverage of the entire testing process through multiple iterations, thus realizing an efficient, low-human-dependent, and continuously optimizable test case generation method.
[0052] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0053] In one embodiment, a test case generation apparatus is provided, which corresponds one-to-one with the test case generation methods in the above embodiments. For example... Figure 4 As shown, the test case generation device includes a receiving module 101, a generation module 102, an execution module 103, and an optimization module 104. Detailed descriptions of each functional module are as follows: The receiving module 101 is used to receive software testing requirements through the requirement analysis agent, extract the test points of the software testing requirements, and construct a target knowledge graph based on the test points; The generation module 102 is used to generate initial test cases based on the test target knowledge graph through the test case generation agent; The execution module 103 is used to execute the initial test cases through the execution verification agent to obtain test results; wherein, the test results include a validity determination of the initial test cases and the basis for the determination; The optimization module 104 is used to respond to the test result determining that the initial test case is an invalid test case, optimize the policy parameters of each agent in the agent system based on the determination criteria by the evolutionary learning agent, and generate new test cases.
[0054] The receiving module 101 is used to parse the software testing requirements based on a natural language processing model through the requirement analysis agent to obtain structured requirement information; extract the test points from the structured requirement information through the requirement analysis agent; wherein the test points include software function points, constraints and target outputs; and construct a target knowledge graph including test objectives and related relationships based on the test points through the requirement analysis agent.
[0055] The generation module 102 is used to receive the test target knowledge graph through the test case generation agent, and to decompose the test targets in the test target knowledge graph into decomposed test tasks; and to generate corresponding initial test cases based on the decomposed test tasks through the test case generation agent using a reinforcement learning algorithm.
[0056] The execution module 103 is used to load and run the initial test case in a preset test environment through the execution verification agent; during the operation of the initial test case, the execution verification agent monitors the running status of the initial test case to obtain running status information, wherein the running status information includes performance indicators and anomaly information; the execution verification agent compares the running status information with the preset expected results to generate a validity judgment and judgment criteria for the initial test case; and the validity judgment and judgment criteria determine the test result of the corresponding initial test case.
[0057] The optimization module 104 is used to: 1) analyze the judgment criteria through the evolutionary learning agent to obtain the root cause pattern that leads to the invalidity of the initial test cases; 2) use a multi-agent reinforcement learning algorithm to synchronously adjust the policy parameters of the requirement analysis agent, the test case generation agent, and the execution verification agent based on the root cause pattern to obtain updated policy parameters; 3) use a Monte Carlo tree search algorithm through the evolutionary learning agent to determine the optimal cooperative topology among each agent; and 4) generate the new test cases through the agent system based on the updated policy parameters and the optimal cooperative topology.
[0058] The optimization module 104 is used to construct a collaborative topology graph with the agent as the node through the evolutionary learning agent; to determine the collaborative efficiency of each topology in a preset topology space based on the collaborative topology graph using the Monte Carlo tree search algorithm through the evolutionary learning agent; and to determine the topology with the highest collaborative efficiency as the optimal collaborative topology through the evolutionary learning agent.
[0059] The generation module 102 is used to store the optimized strategy parameters and the validity information of the corresponding test cases into the test knowledge base through the evolutionary learning agent; when the requirement analysis agent receives new software test requirements, it retrieves historical similar requirements and corresponding historical test strategies from the test knowledge base; and the requirement analysis agent analyzes the current test requirements based on the historical test strategies and generates target test cases.
[0060] This invention provides a test case generation device. By automatically parsing software test requirements and extracting test points through a requirements analysis agent, it effectively reduces the risk of omissions caused by human misunderstanding of requirements, ensuring the accuracy and completeness of the test target knowledge graph construction. Secondly, the test case generation agent generates initial test cases based on the target knowledge graph, ensuring that the initial test cases closely revolve around functional points, constraints, and target outputs, improving the relevance and comprehensiveness of the generated initial test cases. During the test execution phase, the execution verification agent executes the initial test cases and generates test results including validity judgments and their criteria, enabling the system to accurately identify invalid test cases and their failure modes. Furthermore, by using an evolutionary learning agent to optimize the strategy parameters of each agent in the agent system based on the judgment criteria, it achieves adaptive adjustment of test case generation, requirements parsing, and verification strategies, thereby constructing a continuously learning self-evolutionary closed loop. This application not only automatically generates new, higher-quality test cases but also continuously improves the efficiency and coverage of the entire testing process through multiple iterations, thus realizing a highly efficient, low-human-dependent, and continuously optimizable test case generation method.
[0061] Specific limitations regarding the test case generation device can be found in the limitations on the test case generation method described above, and will not be repeated here. Each module in the aforementioned test case generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0062] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements a test case generation method, server-side functions, or steps.
[0063] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements a test case generation method, a client-side function, or step.
[0064] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: The demand analysis agent receives software testing requirements, extracts the test points of the software testing requirements, and constructs a target knowledge graph based on the test points. The test case generation agent generates initial test cases based on the test target knowledge graph. The initial test cases are executed by the execution verification agent to obtain test results; wherein, the test results include a validity determination of the initial test cases and the basis for such determination; In response to the test result determining that the initial test case is invalid, the evolutionary learning agent optimizes the policy parameters of each agent in the agent system based on the determination criteria and generates new test cases.
[0065] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: The demand analysis agent receives software testing requirements, extracts the test points of the software testing requirements, and constructs a target knowledge graph based on the test points. The test case generation agent generates initial test cases based on the test target knowledge graph. The initial test cases are executed by the execution verification agent to obtain test results; wherein, the test results include a validity determination of the initial test cases and the basis for such determination; In response to the test result determining that the initial test case is invalid, the evolutionary learning agent optimizes the policy parameters of each agent in the agent system based on the determination criteria and generates new test cases.
[0066] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0067] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0068] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0069] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for generating test cases, characterized in that, Applied to an intelligent agent system, the intelligent agent system including a communication connection requirement analysis intelligent agent, a use case generation intelligent agent, an execution verification intelligent agent, and an evolutionary learning intelligent agent, the method includes: The demand analysis agent receives software testing requirements, extracts the test points of the software testing requirements, and constructs a target knowledge graph based on the test points. The test case generation agent generates initial test cases based on the test target knowledge graph. The initial test cases are executed by the execution verification agent to obtain test results; wherein, the test results include a validity determination of the initial test cases and the basis for such determination; In response to the test result determining that the initial test case is invalid, the evolutionary learning agent optimizes the policy parameters of each agent in the agent system based on the determination criteria and generates new test cases.
2. The method according to claim 1, characterized in that, The process of receiving software testing requirements through the requirement analysis agent, extracting test points from the software testing requirements, and constructing a target knowledge graph based on the test points includes: The requirement analysis agent parses the software testing requirements using a natural language processing model to obtain structured requirement information. The test points are extracted from the structured requirements information by the requirements analysis agent; wherein, the test points include software function points, constraints and target outputs; The demand analysis agent constructs a target knowledge graph, including test objectives and related relationships, based on the test points.
3. The method according to claim 1, characterized in that, The step of generating initial test cases based on the test target knowledge graph through the test case generation agent includes: The test case generating agent receives the test target knowledge graph and performs task decomposition on the test targets in the test target knowledge graph to obtain the decomposed test tasks. The agent generates corresponding initial test cases based on the decomposed test tasks using the test case generation algorithm.
4. The method according to claim 1, characterized in that, The step of executing the initial test cases through the execution verification agent to obtain test results includes: The execution verification agent loads and runs the initial test cases in a preset test environment; During the execution of the initial test case, the execution verification agent monitors the running status of the initial test case to obtain running status information, which includes performance indicators and anomaly information. The execution verification agent compares the running status information with the preset expected results to generate a validity judgment and judgment basis for the initial test cases; The validity determination and the determination criteria are used to determine the test results of the corresponding initial test cases.
5. The method according to claim 1, characterized in that, In response to the test result determining that the initial test case is invalid, the evolutionary learning agent optimizes the policy parameters of each agent in the agent system based on the determination criteria and generates new test cases, including: The evolutionary learning agent analyzes the judgment criteria to obtain the root cause pattern that causes the initial test case to be invalid. Based on the root cause pattern, the evolutionary learning agent synchronously adjusts the policy parameters of the demand analysis agent, the use case generation agent, and the execution verification agent using a multi-agent reinforcement learning algorithm to obtain updated policy parameters; and... The optimal cooperative topology among the agents is determined by the Monte Carlo tree search algorithm through the evolutionary learning agents. The intelligent agent system generates the new test cases based on the updated policy parameters and the optimal cooperative topology.
6. The method according to claim 5, characterized in that, The step of determining the optimal cooperative topology among each agent using the Monte Carlo tree search algorithm through the evolutionary learning agents includes: The evolutionary learning agent is used to construct a collaborative topology graph with the agent as the node; The evolutionary learning agent uses the Monte Carlo tree search algorithm to determine the collaborative efficiency of each topology in a preset topology space based on the collaborative topology graph. The evolutionary learning agent determines the topology with the highest cooperative efficiency as the optimal cooperative topology.
7. The method according to claim 1, characterized in that, The method further includes: The evolutionary learning agent stores the optimized policy parameters and the validity information of the corresponding test cases into the test knowledge base. When the requirement analysis agent receives new software testing requirements, it retrieves historical similar requirements and corresponding historical testing strategies from the test knowledge base. The requirement analysis agent analyzes the current test requirements based on the historical test strategy and generates target test cases.
8. A test case generation device, characterized in that, Applied to an intelligent agent system, the intelligent agent system includes a communication connection requirement analysis intelligent agent, a use case generation intelligent agent, an execution verification intelligent agent, and an evolutionary learning intelligent agent, including: The receiving module is used to receive software testing requirements through the requirement analysis agent, extract the test points of the software testing requirements, and construct a target knowledge graph based on the test points; The generation module is used to generate initial test cases based on the test target knowledge graph through the test case generation agent; An execution module is used to execute the initial test cases through the execution verification agent to obtain test results; wherein, the test results include a validity determination of the initial test cases and the basis for the determination; An optimization module is used to respond to the test result determining that the initial test case is an invalid test case, and to optimize the policy parameters of each agent in the agent system based on the determination criteria by the evolutionary learning agent, and generate new test cases.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the test case generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the test case generation method as described in any one of claims 1 to 7.