Test case generation method and device, computer equipment and readable storage medium
By embedding test case generation components and intelligent agents into the requirements management platform, test cases can be obtained and edited directly from the requirements management page, solving the problem of low generation efficiency caused by the independence of existing tools and achieving efficient and accurate test case generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
- Filing Date
- 2026-01-29
- Publication Date
- 2026-05-19
AI Technical Summary
Existing automated test case generation tools are independent of the requirements management platform, requiring manual input of requirements, resulting in low generation efficiency.
Embedding a test case generation component in the requirements management platform allows the test case generation agent to directly obtain requirements information from the requirements management page, generate initial test cases, and support online editing to generate target test cases.
It eliminates the need for manual input of requirements, reduces manual operation costs, avoids information omissions, improves the efficiency of test case generation, shortens the connection cycle from requirements to testing, and ensures the accuracy of information transmission and the precision of generation.
Smart Images

Figure CN122064592A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software development technology, and in particular to a test case generation method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Technology
[0002] In software project development, requirements testing is a core component for ensuring product quality. By using test cases covering different scenarios, it verifies the completeness, correctness, and compatibility of requirements. As software functionality becomes increasingly complex, the number of test cases required for requirements testing grows exponentially. Therefore, automated test case generation tools have emerged, which can automatically generate test cases, effectively improving the efficiency of test case generation.
[0003] However, test case automation generation tools in related technologies are generally independent of the requirements management platform. Testers need to manually input the relevant content of the requirements on the requirements management platform into the test case automation generation tool in order to call the test case automation generation tool, which makes the test case generation efficiency still relatively low. Summary of the Invention
[0004] Therefore, it is necessary to address the technical problem of low test case generation efficiency mentioned above by providing a test case generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the test case generation efficiency.
[0005] Firstly, this application provides a test case generation method, including:
[0006] The target requirement management page displays the requirements to be tested through a requirement management platform; the requirement management platform embeds a test case generation component.
[0007] In response to the triggering operation of the test case generation component, the test case generation agent is invoked to generate initial test cases for the requirement to be tested, and the initial test cases are displayed through the requirement management platform; the test case generation agent is used to obtain the target requirement information of the requirement to be tested according to the target requirement management page, and generate the initial test cases based on the target requirement information.
[0008] Based on the editing operations of the initial test cases, the target test cases for the requirement to be tested are obtained.
[0009] In one embodiment, the step of invoking a test case generation agent to generate initial test cases for the requirement to be tested, in response to a trigger operation on the test case generation component, includes:
[0010] In response to a trigger operation on the test case generation component, the page information of the target requirement management page is obtained; the page information includes at least the page address information of the target requirement management page and the requirement identification information of the requirement to be tested;
[0011] The page information is transmitted to the test case generation agent, so that the test case generation agent can call the test case generation model according to the page information and prompt information to obtain the target requirement information and generate the initial test cases.
[0012] The test case generation model is based on a large language model. The test case generation model is used to invoke a model context protocol based on the page information to obtain the target requirement information and generate the initial test cases based on the target requirement information. The model context protocol is used to obtain the initial requirement information of the requirement to be tested from the target requirement management page based on the page information, parse the initial requirement information to obtain the target requirement information, and return the target requirement information to the test case generation model.
[0013] In one embodiment, the initial requirement information includes first requirement information, or includes both first requirement information and second requirement information; the first requirement information is in text form, and the second requirement information is in non-text form.
[0014] The model context protocol is also used to determine the initial requirement information as the target requirement information when the initial requirement information only includes the first requirement information;
[0015] Alternatively, if the initial requirement information includes the first requirement information and the second requirement information, the second requirement information is parsed to obtain the text information corresponding to the second requirement information, and the text information corresponding to the second requirement information is inserted into the initial requirement information to obtain the target requirement information.
[0016] In one embodiment, the prompt information represents the test case generation rules used to generate the initial test case;
[0017] The test case generation model is also used to perform semantic understanding of the target requirement information based on the prompt information, and generate the initial test cases based on the semantic understanding results of the target requirement information.
[0018] In one embodiment, the number of initial test cases is multiple; the editing operation includes at least one of the following: adding, modifying, and deleting.
[0019] After displaying the initial test cases through the requirements management platform, the process also includes:
[0020] In response to a trigger operation on the editing component displayed on the requirements management platform, the user is redirected to the online test case editing page; the online test case editing page includes each of the initial test cases and a test case upload component;
[0021] The process of obtaining target test cases for the requirement to be tested based on editing the initial test cases includes:
[0022] In response to at least one of the operations of adding, modifying and deleting each of the initial test cases in the online test case editing page, a first test case and a second test case are obtained; the first test case includes the initial test cases that have not been modified and have not been deleted, and the second test case includes at least one of the newly added test cases or the modified initial test cases;
[0023] In response to the triggering operation of the test case upload component, the first test case and the second test case in the online test case editing page are uploaded to the requirement management platform as the target test case.
[0024] In one embodiment, each initial test case carries generation method identification information, which is used to characterize that the initial test case is generated by the test case generation agent;
[0025] The method further includes:
[0026] In response to a modification operation on any initial test case, the generation method identification information carried by the initial test case is deleted and the initial test case is modified to obtain the modified initial test case.
[0027] The step of uploading the first test case and the second test case in the online test case editing page as the target test case to the requirements management platform includes:
[0028] Based on the configuration of the generation method identification information of the first test case and the second test case in the online test case editing page, the first test case and the second test case in the online test case editing page are uploaded to the requirement management platform as the target test cases.
[0030] In one embodiment, after uploading the first and second test cases in the online test case editing page as the target test cases to the requirement management platform according to the configuration of the generation method identification information of the first and second test cases in the online test case editing page, the method further includes:
[0031] In response to the test operation on the requirement to be tested, the requirement to be tested is tested according to the target test case;
[0032] Based on the generation method identification information carried by the first test case, the statistical characteristics of the first test case in the target test case are determined; the statistical characteristics include the number of the first test cases and the proportion of the first test cases in the target test case.
[0033] Based on the statistical characteristics of the target test case and the first test case, an optimization strategy for generating the test case agent is generated;
[0034] Based on the optimization strategy, the intelligent agent generated for the test cases is optimized.
[0035] Secondly, this application also provides a test case generation apparatus, comprising:
[0036] The requirement management page display module is used to display the target requirement management page of the requirements to be tested through the requirement management platform; the requirement management platform embeds a test case generation component.
[0037] The initial test case generation module is used to respond to the trigger operation of the test case generation component, call the test case generation agent to generate initial test cases for the requirement to be tested, and display the initial test cases through the requirement management platform; the test case generation agent is used to obtain the target requirement information of the requirement to be tested according to the target requirement management page, and generate the initial test cases based on the target requirement information.
[0038] The target test case determination module is used to obtain target test cases for the requirement to be tested based on the editing operation of the initial test cases.
[0039] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0040] The target requirement management page displays the requirements to be tested through a requirement management platform; the requirement management platform embeds a test case generation component.
[0041] In response to the triggering operation of the test case generation component, the test case generation agent is invoked to generate initial test cases for the requirement to be tested, and the initial test cases are displayed through the requirement management platform; the test case generation agent is used to obtain the target requirement information of the requirement to be tested according to the target requirement management page, and generate the initial test cases based on the target requirement information.
[0042] Based on the editing operations of the initial test cases, the target test cases for the requirement to be tested are obtained.
[0043] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0044] The target requirement management page displays the requirements to be tested through a requirement management platform; the requirement management platform embeds a test case generation component.
[0045] In response to the triggering operation of the test case generation component, the test case generation agent is invoked to generate initial test cases for the requirement to be tested, and the initial test cases are displayed through the requirement management platform; the test case generation agent is used to obtain the target requirement information of the requirement to be tested according to the target requirement management page, and generate the initial test cases based on the target requirement information.
[0046] Based on the editing operations of the initial test cases, the target test cases for the requirement to be tested are obtained.
[0047] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0048] The target requirement management page displays the requirements to be tested through a requirement management platform; the requirement management platform embeds a test case generation component.
[0049] In response to the triggering operation of the test case generation component, the test case generation agent is invoked to generate initial test cases for the requirement to be tested, and the initial test cases are displayed through the requirement management platform; the test case generation agent is used to obtain the target requirement information of the requirement to be tested according to the target requirement management page, and generate the initial test cases based on the target requirement information.
[0050] Based on the editing operations of the initial test cases, the target test cases for the requirement to be tested are obtained.
[0051] The aforementioned test case generation method, apparatus, computer device, computer-readable storage medium, and computer program product, in response to a trigger operation on a test case generation component embedded in a requirements management platform, can invoke a test case generation agent to obtain target requirement information of the requirement to be tested from the target requirement management page of the requirement to be tested displayed on the requirements management platform, and generate initial test cases for the requirement to be tested based on the target requirement information. By displaying the initial test cases on the requirements management platform, users can easily determine whether the initial test cases need to be edited, thereby obtaining target test cases that better match the requirement to be tested. Based on the above process, the test case generation agent can automatically obtain the target requirement information of the target requirement management page of the requirement to be tested from the requirements management platform and generate initial test cases, eliminating the need for testers to manually input the target requirement information into the test case generation agent, thus improving the efficiency of test case generation. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0053] Figure 1 This is a diagram illustrating the application environment of a test case generation method in one embodiment.
[0054] Figure 2 This is a flowchart illustrating a test case generation method in one embodiment;
[0055] Figure 3 This is a flowchart illustrating the steps of invoking a test case generation agent to generate initial test cases for the requirements to be tested in response to a triggering operation on the test case generation component, as shown in one embodiment.
[0056] Figure 4 This is a schematic diagram illustrating the generation of initial test cases by a test case generation agent in one embodiment.
[0057] Figure 5 This is a schematic diagram illustrating how the model context protocol obtains target requirement information in one embodiment.
[0058] Figure 6 This is a flowchart illustrating the steps of testing the requirements to be tested and optimizing the intelligent agents generated from the test cases in one embodiment.
[0059] Figure 7 This is a flowchart illustrating a lightweight intelligent test case generation method in one embodiment;
[0060] Figure 8 This is a structural block diagram of a test case generation device in one embodiment;
[0061] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0063] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0064] The test case generation method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, server 102 communicates with terminal 104 via a network. A data storage system can store the data that server 102 needs to process. This data storage system can be integrated onto server 102 or located on a cloud or other network server. Server 102 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Server 102 serves as the backend server for the requirements management platform and the test case generation plugin embedded within it. The requirements management platform and the test case generation plugin can be distributed on the same server or on different servers. Terminal 104 is a terminal running the software application of the requirements management platform, and can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices.
[0065] For example, firstly, server 102 displays the target requirement management page of the requirement to be tested through the requirement management platform running on terminal 104; the requirement management platform embeds and displays a test case generation component; then, in response to the trigger operation of the test case generation component, server 102 calls the test case generation agent to generate initial test cases for the requirement to be tested, and displays the initial test cases through the requirement management platform; the test case generation agent is used to obtain the target requirement information of the requirement to be tested according to the target requirement management page, and generate initial test cases based on the target requirement information; then, server 102 obtains the target test cases for the requirement to be tested based on the editing operation of the initial test cases.
[0066] In some embodiments, such as Figure 2 As shown, a test case generation method is provided, which can be applied to... Figure 1 Taking the server in the example, the following steps are included:
[0067] Step S202: Display the target requirement management page of the requirement to be tested through the requirement management platform.
[0068] The requirements management platform is a software platform used to manage requirements, enabling the editing, publishing, and testing of requirements. For example, the requirements management platform can also manage software projects, such as the development, testing, and release of software projects.
[0069] The demand management platform's software application runs on a terminal that communicates with the server, and the terminal displays the demand management platform's user interface.
[0070] In the requirements management platform, each requirement corresponds to a requirements management page, where the requirements can be managed. The target requirements management page for the requirement to be tested refers to the requirements management page for the requirement to be tested.
[0071] The requirements management platform embeds a test case generation plugin, which generates test cases through a test case generation agent. The test case generation agent includes a test case generation model and a model context protocol. The model context protocol is a standardized protocol that defines a set of standard interfaces, enabling large language models to securely and flexibly connect to and call various external data sources, tools, and services. The requirements management platform's user interface also embeds and displays a test case generation component, which is used to initiate the call to the test case generation plugin.
[0072] In this step, the server displays the target requirement management page and test case generation component for the requirements to be tested through the terminal's operation interface.
[0073] For example, the target requirement management page and the test case generation component can be displayed independently or integrated. For instance, the user interface can be divided into a page display area and a plugin display area, with the target requirement management page displayed in the page display area and the test case generation component displayed in the plugin display area. Alternatively, each requirement management page can display the test case generation component.
[0074] Step S204: In response to the trigger operation of the test case generation component, the test case generation agent is invoked to generate initial test cases for the requirements to be tested, and the initial test cases are displayed through the requirements management platform.
[0075] Among them, the test case generation agent is used to obtain the target requirement information of the requirement to be tested from the target requirement management page, and generate initial test cases based on the target requirement information.
[0076] Among them, the target requirement information of the requirement to be tested is used to characterize the requirement content, test content, test requirements, test objectives and other specific content related to the requirement and its test.
[0077] In this step, when a user needs to test the test cases, they can trigger the test case generation component displayed in the operation interface, for example, by clicking the test case generation component; the server responds to the user's trigger operation on the test case generation component by calling the test case generation plugin embedded in the requirement management platform, and the test case generation plugin further calls the test case generation agent to generate initial test cases for the requirements to be tested; the server returns the generated initial test cases to the terminal; the terminal displays the initial test cases through the operation interface.
[0078] In practical applications, the number of initial test cases is at least one.
[0079] Step S206: Based on the editing operation of the initial test cases, the target test cases for the requirements to be tested are obtained.
[0080] The editing operation includes at least one of the following: adding, modifying, and deleting.
[0081] In this step, in response to the user's editing operation on the initial test case on the terminal, the terminal obtains the target test case of the requirement to be tested and returns it to the server.
[0082] In practical applications, the number of target test cases is at least one.
[0083] For example, after the user triggers the test case generation component, the terminal creates a floating layer on the target requirement management page in the operation interface of the requirement management platform. When the initial test case is received, it is displayed in the floating layer. The floating layer also contains an editing component. When the tester triggers the editing component, for example, by clicking the editing component, the terminal will jump to the online test case editing page. The test case generation plugin will copy the initial test case from the floating layer to the online test case editing page so that the tester can edit the initial test case in the online test case editing page.
[0084] Furthermore, if the overlay supports editing of the displayed content, testers can also directly edit the initial test cases in the overlay on the target requirements management page.
[0085] For example, after obtaining the target test cases, the terminal can display the target test cases in a floating layer.
[0086] In the above test case generation method, in response to a trigger operation on the test case generation component embedded in the requirements management platform, the test case generation agent can be invoked to obtain the target requirement information of the requirement to be tested from the target requirement management page of the requirement to be tested displayed on the requirements management platform, and generate initial test cases for the requirement to be tested based on the target requirement information. By displaying the initial test cases through the requirements management platform, users can easily determine whether the initial test cases need to be edited, thereby obtaining target test cases that better match the requirement to be tested. Based on the above process, the test case generation agent can automatically obtain the target requirement information from the target requirement management page of the requirement to be tested from the requirements management platform and generate initial test cases, without requiring testers to manually input the target requirement information into the test case generation agent, thus improving the efficiency of test case generation.
[0087] Furthermore, in this embodiment, by embedding a test case generation plugin into the requirements management platform, this application breaks down the independent barriers between automated test case generation tools and the requirements management platform. This eliminates the redundant step of "manually inputting requirements content" at its source, eliminating the need for testers to extract, organize, and input across platforms. This not only reduces manual operation costs but also avoids potential information omissions and mistypes during manual input, ensuring the accuracy of information transmission and laying the foundation for the precision of subsequent test case generation. Simultaneously, this embodiment also constructs a closed-loop test case generation process encompassing "requirements presentation - test case generation - test case editing," significantly shortening the transition cycle from requirements to testing, reducing time spent on tool switching and data import, and significantly improving the efficiency of test case generation, thereby enhancing the overall efficiency of requirements testing.
[0088] In some embodiments, such as Figure 3 As shown, step S204 above, in response to the triggering operation of the test case generation component, calls the test case generation agent to generate initial test cases for the requirements to be tested, including the following steps:
[0089] Step S302: In response to the triggering operation of the test case generation component, obtain the page information of the target requirement management page.
[0090] Step S304: The page information is transmitted to the test case generation agent, so that the test case generation agent can call the test case generation model according to the page information and prompt information to obtain the target requirement information and generate the initial test cases.
[0091] The page information includes at least the page address information of the target requirement management page and the requirement identification information of the requirement to be tested; for example, the page address information is the page address, and the requirement identification information is information that can uniquely identify the requirement, such as the requirement ID (Identity document).
[0092] The test case generation model is derived from a large language model, for example, using a large language model as the test case generation model. Furthermore, the test case generation model is derived from a multimodal large language model, for example, using a multimodal large language model as the test case generation model. The test case generation model is used to invoke the model context protocol based on page information to obtain target requirement information and generate initial test cases based on the target requirement information. The model context protocol is used to obtain the initial requirement information of the requirement to be tested from the target requirement management page based on page information, parse the initial requirement information to obtain the target requirement information, and return the target requirement information to the test case generation model.
[0093] The initial requirements information consists of all the information on the target requirements management page.
[0094] The prompts are the prompts from the test case generation model.
[0095] In this embodiment, the server responds to the user's trigger operation on the test case generation component by obtaining the page information of the target requirement management page currently displayed on the terminal. Then, the server transmits the page information to the test case generation plugin to invoke it; after being invoked, the test case generation plugin further invokes the test case generation agent. For example... Figure 4The diagram illustrates the process of a test case generation agent generating initial test cases. After being invoked, the test case generation agent further invokes the test case generation model based on page information and prompts. The test case generation model, in turn, invokes the test case generation agent's model context protocol based on page information. Upon invocation, the model context protocol retrieves the initial requirement information of the requirement to be tested from the target requirement management page, parses the initial requirement information to obtain the target requirement information, and returns the target requirement information to the test case generation model. The test case generation model then generates initial test cases based on the target requirement information returned by the model context protocol.
[0096] In this embodiment, the server can accurately indicate the requirements to be tested to the test case generation agent through page information, thereby enabling the test case generation agent to accurately and quickly obtain relevant information about the requirements to be tested. This reduces the cost of manual operation and avoids problems such as information omissions and mis-typing that may occur during manual input, ensuring the accuracy of information transmission and laying the foundation for the accuracy of subsequent test case generation.
[0097] In some embodiments, the initial requirement information includes first requirement information, or includes both first requirement information and second requirement information; the first requirement information is in text form, and the second requirement information is in non-text form, such as images, design drafts, etc.
[0098] In one embodiment, the model context protocol is further configured to determine the initial requirement information as the target requirement information when the initial requirement information only includes first requirement information.
[0099] In this embodiment, the model context protocol determines the initial requirement information as the target requirement information when the initial requirement information only includes the first requirement information, that is, the initial requirement information only includes text content.
[0100] In another embodiment, the model context protocol is also used to parse the second requirement information to obtain the text information corresponding to the second requirement information when the initial requirement information includes the first requirement information and the second requirement information, and to insert the text information corresponding to the second requirement information into the initial requirement information to obtain the target requirement information.
[0101] In this embodiment, as Figure 5The diagram illustrates how the Model Context Protocol (MTP) obtains target requirement information. When the initial requirement information includes both first and second requirement information (i.e., in addition to text content, the initial requirement information also includes non-text content such as images and design drafts), the MTP parses the second requirement information (i.e., the non-text content) to obtain the corresponding text information (i.e., the parsed text result of the non-text content). This text information is then inserted into the initial requirement information to obtain the target requirement information. In practical applications, if a parsing exception occurs (e.g., parsing fails) or a parsing timeout occurs during the parsing of the second requirement information, the test case generation model ends the parsing and inserts the parsed text information into the initial requirement information.
[0102] For example, the server inserts the text information of the second requirement information before or after the second requirement information.
[0103] In this embodiment, the model context protocol can obtain complete target requirement information that is easy for large language models to understand and process based on different forms of requirement information, thereby laying the foundation for accurate generation of test cases in the future.
[0104] In some embodiments, the prompt information represents the test case generation rules used to generate initial test cases; for example, the test case generation rules include at least test case writing rules, test case output format specifications, and test case examples.
[0105] In this embodiment, the test case generation model is also used to perform semantic understanding of the target requirement information and generate initial test cases based on the semantic understanding results of the target requirement information.
[0106] For example, the test case generation model is also used to perform semantic understanding of the target requirement information based on the test case writing rules, test case output format specifications and test case examples, obtain the semantic understanding result, and generate initial test cases based on the semantic understanding result using its own semantic generation capability.
[0107] In some exemplary embodiments, the prompt information is also used to instruct the test case generation model, when it is determined from the knowledge base of the software project to which the requirement to be tested belongs based on the target requirement information, to obtain historical information associated with the requirement to be tested from the knowledge base of the software project, and to improve the target requirement information based on the historical information to generate initial test cases.
[0108] In this embodiment, the server's semantic understanding and semantic generation capabilities based on the large language model enable the test case generation model to accurately generate test cases in accordance with the set rules.
[0109] In some embodiments, the number of initial test cases is multiple; the editing operation includes at least one of the following: adding, modifying, and deleting; wherein, adding refers to manually adding test cases, modifying refers to manually modifying the content or order of the initial test cases, and deleting refers to manually deleting the initial test cases.
[0110] In step S204 above, after displaying the initial test cases through the requirements management platform, the following steps are included: in response to the triggering operation of the editing component displayed on the requirements management platform, the user is redirected to the online test case editing page.
[0111] The online test case editing page displays various initial test cases and a test case upload component.
[0112] Step S206 above, based on the editing operation of the initial test cases, obtains the target test cases for the requirements to be tested, including the following steps: in response to at least one of the operations of adding, modifying and deleting each initial test case in the online test case editing page, a first test case and a second test case are obtained; in response to the triggering operation of the test case upload component, the first test case and the second test case in the online test case editing page are uploaded to the requirement management platform as target test cases.
[0113] The first test case includes the initial test case that has not been modified or deleted.
[0114] The second test case includes at least one of the newly added test cases or the modified initial test cases.
[0115] In this embodiment, while displaying each initial test case through the operation interface, the terminal also displays an editing component through the operation interface. Testers can trigger the editing component, for example, by clicking the editing component, when they need to edit the initial test cases, such as adding test cases, modifying the content or order of initial test cases, or deleting initial test cases. In response to the user's triggering operation of the editing component, the terminal jumps to the online test case editing page. The test case generation plugin copies each initial test case to the online test case editing page, which supports editing of each initial test case. In response to the tester's editing of each initial test case within the online test case editing page... If at least one of the operations of adding, modifying, or deleting test cases is performed, the terminal can obtain a first test case including an initial test case that has not been modified or deleted, and a second test case including the newly added test case and / or the modified initial test case. The online test case editing page also displays a test case upload component. After completing the editing, the tester can trigger the test case upload component, for example, by clicking the test case upload component. In response to the tester's triggering operation on the test case upload component, the test case generation plugin uploads the first and second test cases in the online test case editing page as target test cases to the requirements management platform.
[0116] In practical applications, in response to the tester's editing operations, the terminal can display the tester's edited content in real time on the online test case editing page.
[0117] In this embodiment, testers can edit and optimize test cases through automatic copying and page navigation, which can shorten the connection cycle from requirements to testing and further improve the overall efficiency of requirements testing.
[0118] In some embodiments, each initial test case carries generation method identification information, which is used to characterize that the initial test case is generated by a test case generation agent.
[0119] In this embodiment, the test case generation method provided by this application further includes the following steps: in response to a modification operation on any initial test case, deleting the generation method identification information carried by the initial test case and modifying the initial test case to obtain a modified initial test case.
[0120] For example, if a tester modifies any initial test case, the terminal deletes the generation method identification information carried by the initial test case and modifies the initial test case. The modified initial test case is then the modified initial test case.
[0121] In this embodiment, the steps described above, uploading the first and second test cases in the online test case editing page as target test cases to the requirements management platform, include the following steps: displaying the test case upload component through the requirements management platform; and uploading the first and second test cases in the online test case editing page as target test cases to the requirements management platform according to the configuration of the generation method identification information of the first and second test cases in the online test case editing page.
[0122] For example, in response to the user's triggering operation on the test case upload component in the online test case editing page, the terminal uploads each test case in the target test case to the server according to the configuration of the generation method identification information of each test case in the target test case, so that the server can save them to the storage space corresponding to the requirements management platform.
[0123] Among them, differentiated upload refers to using different upload methods for test cases with different generation method identification information configurations.
[0124] In one embodiment, the configuration of test case generation method identification information refers to whether or not generation method identification information is configured. For example, test cases carrying generation method identification information (i.e., the first test case) are uploaded to one partition of the storage space, while test cases without generation method identification information (i.e., the second test case) are uploaded to another partition of the storage space; or, for test cases carrying generation method identification information, the generation method identification information is included during the upload process, while test cases without generation method identification information are uploaded directly.
[0125] In another embodiment, the second test case also carries generation method identification information; the initial test case (i.e., the first test case) carries generation method identification information of the first generation method, and the second test case carries generation method identification information of the second generation method, used to indicate that the second test case was obtained through manual editing. In this embodiment, in response to a modification operation on any initial test case, the terminal deletes the first generation method identification information carried by the initial test case, modifies the initial test case to obtain a modified initial test case, and then adds the second generation method identification information to the modified initial test case. In this embodiment, the configuration of the generation method identification information of the test case refers to whether the configured generation method identification information is the first generation method identification information or the second generation method identification information. For example, the test case carrying the first generation method identification information is uploaded to one partition of the storage space, and the test case carrying the second generation method identification information is uploaded to another partition of the storage space; or, for the test case carrying the first generation method identification information, it is uploaded with its first generation method identification information, and for the test case carrying the second generation method identification information, it is uploaded with its second generation method identification information. Furthermore, the first generation method identification information can be further subdivided into those that have not been manually modified and those that have not been manually deleted, and the second generation method identification information can be further subdivided into those that have been newly added and those that have been modified.
[0126] In other embodiments, the terminal is also used to display target test cases on the operation interface; at this time, the terminal can also mark and prompt the first test case through the first marking information, such as highlighting it, so that testers can quickly locate the first test case in the target test case. Furthermore, the terminal can also mark and prompt the second test case through the second marking information, such as highlighting it, so that testers can quickly locate the second test case in the target test case. For example, the terminal can also highlight the modified part of the modified initial test case in the second test case.
[0127] In this embodiment, the first test case and the second test case can be distinguished by configuring and deleting the generation method identification information.
[0128] In some embodiments, such as Figure 6 As shown, in the above steps, after uploading the first and second test cases in the online test case editing page as target test cases to the requirement management platform according to the configuration of the generation method identification information of the first and second test cases in the online test case editing page, the following steps are also included to test the requirements to be tested and optimize the test case generation agent:
[0129] Step S602: In response to the test operation of the test requirement, test the test requirement according to the target test case.
[0130] Step S604: Determine the statistical characteristics of the first test case in the target test case based on the generation method identification information carried by the first test case.
[0131] Step S606: Based on the statistical characteristics of the target test case and the first test case, generate an optimization strategy for the test case generation agent.
[0132] Step S608: Optimize the generated agent for the test cases according to the optimization strategy.
[0133] Among them, the statistical characteristics include at least the number of first test cases and the proportion of first test cases in the target test cases.
[0134] In this embodiment, the terminal displays the target test case through an operation interface. After determining that the target test case can be used for requirement testing, the user can trigger the requirement testing component displayed in the operation interface, for example, by clicking the requirement testing component. In response to the user's triggering operation of the requirement testing component, the server tests the requirement to be tested according to the target test case. After completing the requirement testing, the server determines the number and proportion of statistical features of the first test case in the target test case based on the generation method identification information carried by the first test case, and obtains the statistical features of the first test case. Then, based on the statistical features of the first test case, the server evaluates whether the test case generation agent needs to be optimized. If the evaluation indicates that the test case generation agent needs to be optimized, an optimization strategy for the test case generation agent is generated based on the statistical features of the target test case and the first test case. The test case generation agent is then optimized according to the optimization strategy, forming a data-driven, back-engineering, continuous improvement mechanism for the test case generation agent to generate more comprehensive test cases.
[0135] In this embodiment, the server can perform testing on the requirements to be tested through the target test cases; by measuring the number and proportion of statistical features of the first test case in the target test cases, it can evaluate whether the test case generating agent needs to be optimized and generate corresponding optimization strategies, thereby forming a data-driven, reverse-engineering test case generating agent to generate more comprehensive test cases and continuously improve the mechanism.
[0136] In some embodiments, after determining the statistical characteristics of the first test case in the target test case in step S604 above, the following step is further included: generating a corresponding report based on the target test case, the statistical characteristics of the first test case, the requirement test results of the requirement to be tested, and the attribute information of the requirement to be tested.
[0137] The attribute information of the requirement to be tested includes at least the requirement identifier, the project identifier of the software project to which the requirement belongs, and the iteration identifier of the iteration to which it belongs. In practical applications, a software project includes multiple iterations, and each iteration contains multiple requirements.
[0138] To more clearly illustrate the test case generation method provided in the embodiments of this application, the following specific embodiment is used to describe the test case generation method in detail. However, it should be understood that the embodiments of this application are not limited thereto. In some embodiments, such as Figure 7 As shown, this application also provides a lightweight intelligent test case generation method, which specifically includes the following steps:
[0139] 1. Embed a test case generation plugin in the requirements management platform. This plugin generates test cases by calling a test case generation agent. The test case generation agent includes a test case generation model and a model context protocol. The test case generation model is a multimodal large language model.
[0140] 2. When test cases need to be written after the requirements have been reviewed, testers can directly click on the test case generation component corresponding to the test case generation plugin to call the test case generation agent through the test case generation plugin.
[0141] 3. The test case generation agent obtains the URL and requirement identification information of the requirement management page currently displayed on the requirement management platform, and inputs the URL and requirement identification information into the test case generation model.
[0142] 4. The test case generation model calls the model context protocol based on the URL and requirement identification information; the model context protocol accesses the corresponding requirement management page, obtains the initial requirement information of the requirement to be tested, parses it, and returns the target requirement information to the test case generation model.
[0143] 5. The test case generation model generates corresponding initial test cases based on the target requirement information and preset test case generation rules.
[0144] 6. The requirements management platform displays the initial test cases and responds to the testers' editing operations to obtain and save the target test cases. The requirements management platform tests the requirements to be tested based on the target test cases, and after the test is completed, it statistically analyzes the test cases generated by the test case generation model in the target test cases and writes a global data report on the testing process of the requirements to be tested based on the statistical characteristics.
[0145] 7. Continuously optimize test case generation and intelligent agents based on global data reports, address shortcomings in generation, and improve efficiency.
[0146] In this embodiment, on the one hand, the test case generation plugin can be applied to any requirement management platform. It only needs to obtain requirement keywords, such as URLs and requirement identifiers, to intelligently generate requirement test cases. The entire solution is lightweight and fits the daily testing workflow of testers, without increasing workload and improving efficiency. On the other hand, this embodiment also allows for manual adjustment of prompts in the large model to debug the test case generation effect, offering flexibility and convenience. Testers can also flexibly supplement or modify test cases manually, minimizing manual operations. Furthermore, this embodiment can generate objective usage data based on the actual usage of test cases by testers. Using real data to infer better test case generation results forms a virtuous cycle of test case generation – generation data collection – inferring generation effect – optimizing the intelligent agent. Moreover, this embodiment solves the problem of test cases being managed locally by testers after manually executing requirement testing. Unified test case uploads can accumulate a business-related test case knowledge base, facilitating its use by other capabilities.
[0147] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0148] Based on the same inventive concept, this application also provides a test case generation apparatus for implementing the test case generation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more test case generation apparatus embodiments provided below can be found in the limitations of the test case generation method described above, and will not be repeated here.
[0149] In some embodiments, such as Figure 8 As shown, a test case generation device is provided, including: a requirements management page display module 802, an initial test case generation module 804, and a target test case determination module 806, wherein:
[0150] The requirement management page display module 802 is used to display the target requirement management page of the requirements to be tested through the requirement management platform; the requirement management platform embeds and displays a test case generation component.
[0151] The initial test case generation module 804 is used to respond to the trigger operation of the test case generation component, call the test case generation agent to generate initial test cases for the requirements to be tested, and display the initial test cases through the requirements management platform; the test case generation agent is used to obtain the target requirement information of the requirements to be tested from the target requirement management page, and generate initial test cases based on the target requirement information.
[0152] The target test case determination module 806 is used to obtain target test cases for the requirements to be tested based on the editing operations of the initial test cases.
[0153] In one embodiment, the initial test case generation module 804 is further configured to, in response to a trigger operation on the test case generation component, obtain page information of the target requirement management page; the page information includes at least the page address information of the target requirement management page and the requirement identification information of the requirement to be tested; transmit the page information to the test case generation agent, so that the test case generation agent calls the test case generation model according to the page information and prompt information to obtain the target requirement information and generate initial test cases; wherein, the test case generation model is based on a large language model; the test case generation model is configured to call the model context protocol according to the page information to obtain the target requirement information and generate initial test cases based on the target requirement information; the model context protocol is configured to, according to the page information, obtain the initial requirement information of the requirement to be tested from the target requirement management page, parse the initial requirement information to obtain the target requirement information, and return the target requirement information to the test case generation model.
[0154] In one embodiment, the initial requirement information includes first requirement information, or includes both first requirement information and second requirement information; the first requirement information is in text form, and the second requirement information is in non-text form.
[0155] The model context protocol is also used to determine the initial requirement information as the target requirement information when the initial requirement information only includes the first requirement information; or, when the initial requirement information includes the first requirement information and the second requirement information, to parse the second requirement information to obtain the text information corresponding to the second requirement information, and to insert the text information corresponding to the second requirement information into the initial requirement information to obtain the target requirement information.
[0156] In one embodiment, the prompt information represents the test case generation rules used to generate the initial test cases.
[0157] The test case generation model is also used to perform semantic understanding of the target requirement information based on the prompt information, and to generate initial test cases based on the semantic understanding results of the target requirement information.
[0158] In one embodiment, the number of initial test cases is multiple; the editing operation includes at least one of the following: add operation, modify operation, and delete operation.
[0159] The target test case determination module 806 is further configured to, in response to a trigger operation on the editing component displayed on the requirements management platform, redirect to the online test case editing page; the online test case editing page includes each initial test case and a test case upload component; in response to at least one of the add, modify, and delete operations on each initial test case within the online test case editing page, a first test case and a second test case are obtained; the first test case includes the initial test case that has not been modified or deleted, and the second test case includes at least one of the newly added test case or the modified initial test case; in response to a trigger operation on the test case upload component, the first and second test cases within the online test case editing page are uploaded to the requirements management platform as target test cases.
[0160] In one embodiment, each initial test case carries generation method identification information, which is used to characterize that the initial test case is generated by the test case generation agent.
[0161] The initial test case generation module 804 is also used to respond to any modification operation of the initial test case by deleting the generation method identification information carried by the initial test case and modifying the initial test case to obtain the modified initial test case.
[0162] The target test case determination module 806 is also used to upload the first and second test cases in the online test case editing page as target test cases to the requirements management platform, based on the configuration of the generation method identification information of the first and second test cases in the online test case editing page.
[0163] In one embodiment, the test case generation apparatus further includes a test module for the requirement to be tested, which is used to test the requirement to be tested according to the target test case in response to a test operation on the requirement to be tested.
[0164] The test case generation device also includes a continuous optimization module for the agent, which is used to determine the statistical characteristics of the first test case in the target test case based on the generation method identification information carried by the first test case; the statistical characteristics include the number of the first test cases and the proportion of the first test cases in the target test case; based on the statistical characteristics of the target test cases and the first test cases, an optimization strategy for the test case generation agent is generated; and the test case generation agent is optimized according to the optimization strategy.
[0165] 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, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0166] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data related to software projects and requirements. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a test case generation method.
[0167] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0168] In some embodiments, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0169] In some embodiments, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0170] In some embodiments, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0171] Those skilled in the art will understand that all or part of the processes in the methods of 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, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0172] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0173] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A test case generation method, characterized in that, The method includes: The target requirement management page displays the requirements to be tested through a requirement management platform; the requirement management platform embeds a test case generation component. In response to the triggering operation of the test case generation component, the test case generation agent is invoked to generate initial test cases for the requirement to be tested, and the initial test cases are displayed through the requirement management platform; the test case generation agent is used to obtain the target requirement information of the requirement to be tested according to the target requirement management page, and generate the initial test cases based on the target requirement information. Based on the editing operations of the initial test cases, the target test cases for the requirement to be tested are obtained.
2. The method according to claim 1, characterized in that, The step of responding to a trigger operation on the test case generation component by invoking a test case generation agent to generate initial test cases for the requirement to be tested includes: In response to a trigger operation on the test case generation component, the page information of the target requirement management page is obtained; the page information includes at least the page address information of the target requirement management page and the requirement identification information of the requirement to be tested; The page information is transmitted to the test case generation agent, so that the test case generation agent can call the test case generation model according to the page information and prompt information to obtain the target requirement information and generate the initial test cases. The test case generation model is based on a large language model. The test case generation model is used to invoke a model context protocol based on the page information to obtain the target requirement information and generate the initial test cases based on the target requirement information. The model context protocol is used to obtain the initial requirement information of the requirement to be tested from the target requirement management page based on the page information, parse the initial requirement information to obtain the target requirement information, and return the target requirement information to the test case generation model.
3. The method according to claim 2, characterized in that, The initial requirement information includes first requirement information, or includes both first requirement information and second requirement information; the first requirement information is in text form, and the second requirement information is in non-text form. The model context protocol is also used to determine the initial requirement information as the target requirement information when the initial requirement information only includes the first requirement information; Alternatively, if the initial requirement information includes the first requirement information and the second requirement information, the second requirement information is parsed to obtain the text information corresponding to the second requirement information, and the text information corresponding to the second requirement information is inserted into the initial requirement information to obtain the target requirement information.
4. The method according to claim 2, characterized in that, The prompt information represents the test case generation rules used to generate the initial test cases; The test case generation model is also used to perform semantic understanding of the target requirement information based on the prompt information, and generate the initial test cases based on the semantic understanding results of the target requirement information.
5. The method according to any one of claims 1 to 4, characterized in that, The number of initial test cases is multiple; the editing operation includes at least one of the following: add operation, modify operation, and delete operation; After displaying the initial test cases through the requirements management platform, the process also includes: In response to a trigger operation on the editing component displayed on the requirements management platform, the user is redirected to the online test case editing page; the online test case editing page includes each of the initial test cases and a test case upload component; The process of obtaining target test cases for the requirement to be tested based on editing the initial test cases includes: In response to at least one of the operations of adding, modifying and deleting each of the initial test cases in the online test case editing page, a first test case and a second test case are obtained; the first test case includes the initial test cases that have not been modified and have not been deleted, and the second test case includes at least one of the newly added test cases or the modified initial test cases; In response to the triggering operation of the test case upload component, the first test case and the second test case in the online test case editing page are uploaded to the requirement management platform as the target test case.
6. The method according to claim 5, characterized in that, Each initial test case carries generation method identification information, which is used to indicate that the initial test case is generated by the test case generation agent; The method further includes: In response to a modification operation on any initial test case, the generation method identification information carried by the initial test case is deleted and the initial test case is modified to obtain the modified initial test case. The step of uploading the first test case and the second test case in the online test case editing page as the target test case to the requirements management platform includes: Based on the configuration of the generation method identification information of the first test case and the second test case in the online test case editing page, the first test case and the second test case in the online test case editing page are uploaded to the requirement management platform as the target test cases.
7. The method according to claim 6, characterized in that, After uploading the first and second test cases from the online test case editing page as the target test cases to the requirements management platform according to the configuration of the generation method identification information of the first and second test cases in the online test case editing page, the process further includes: In response to the test operation on the requirement to be tested, the requirement to be tested is tested according to the target test case; Based on the generation method identification information carried by the first test case, the statistical characteristics of the first test case in the target test case are determined; the statistical characteristics include the number of the first test cases and the proportion of the first test cases in the target test case. Based on the statistical characteristics of the target test case and the first test case, an optimization strategy for generating the test case agent is generated; Based on the optimization strategy, the intelligent agent generated for the test cases is optimized.
8. A computer 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.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.