A test case generation method and apparatus
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-20
- Publication Date
- 2026-08-11
AI Technical Summary
[0004]但是,利用这种方法生成的测试用例的功能覆盖率较低
[0024] The test case generation tool can acquire target test requirements and generate first prompts based on these requirements and a first set of preset content used to generate the functionalities to be tested. Then, the tool inputs these prompts into a large model for reasoning, resulting in the functionalities to be tested corresponding to the target test requirements. Further, the tool can generate second prompts based on the target test requirements, the functionalities to be tested, and a second set of preset content used to generate test case designs. These second prompts are then input into the large model for reasoning, resulting in the test case designs corresponding to the functionalities to be tested. Finally, the tool can generate third prompts based on the target test requirements, the functionalities to be tested, the test case designs, and a third set of preset content used to generate test cases. These third prompts are then input into the large model for reasoning, resulting in the test cases corresponding to the test case designs. In this way, the test case generation tool can analyze the target test requirements using a large model, improving the comprehensiveness of the analysis compared to testers analyzing the target test requirements themselves. Consequently, test cases generated by the test case generation tool using the large model have higher functional coverage than test cases written by testers. Furthermore, test case generation tools can improve the efficiency of test case generation by using large models to generate test cases compared to testers writing test cases.
Smart Images

Figure CN122547683A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software testing technology, and in particular to a test case generation method and apparatus. Background Technology
[0002] During product development, errors are inevitable. Therefore, after product development is complete, testers typically need to test the product to prevent losses caused by defective products being put into practical use. For example, testers usually test nuclear power plant instrumentation and control system software products after development is finished.
[0003] Currently, after receiving the test requirements document, testers analyze the test requirements within it and extract the functionalities to be tested based on the test requirements and design information of the product under test. Then, based on the analyzed functionalities to be tested, testers design test cases and write the corresponding test cases, thus completing the test case writing process.
[0004] However, the test cases generated using this method have low functional coverage. Furthermore, this method is relatively inefficient in generating test cases. Summary of the Invention
[0005] This application provides a test case generation method to improve the functional coverage of test cases and increase the efficiency of test case generation. Furthermore, this application also provides a corresponding test case generation apparatus, computer equipment, and computer-readable storage medium.
[0006] In a first aspect, this application provides a test case generation method, the method comprising: obtaining a target test requirement; generating a first prompt word based on the target test requirement and a first preset content, wherein the first preset content is used to provide a basis for generating a function point to be tested; inputting the first prompt word into a large model for reasoning to obtain the function point to be tested corresponding to the target test requirement; generating a second prompt word based on the target test requirement, the function point to be tested, and a second preset content, wherein the second preset content is used to provide a basis for generating test case designs; inputting the second prompt word into the large model for reasoning to obtain test case designs corresponding to the function point to be tested; generating a third prompt word based on the target test requirement, the function point to be tested, the test case designs, and a third preset content, wherein the third preset content is used to provide a basis for generating test cases; and inputting the third prompt word into the large model for reasoning to obtain test cases corresponding to the test case designs.
[0007] In one possible implementation, the target testing requirement includes the content of the target testing requirement; generating a first prompt word based on the target testing requirement and the first preset content includes: calculating multiple cosine similarities between the content of the target testing requirement and multiple pieces of preset content in a preset vector library, each cosine similarity being obtained based on the content of the target testing requirement and a piece of preset content; determining at least one piece of preset content as the first preset content in the preset vector library based on the multiple cosine similarities; and generating a first prompt word based on the content of the target testing requirement and the first preset content.
[0008] In one possible implementation, obtaining the target test requirement includes: obtaining a test requirement file, the test requirement file including at least one test requirement; displaying the at least one test requirement in a first area; and determining the target test requirement from the at least one test requirement in response to a first operation on the area where the target test requirement is located.
[0009] In one possible implementation, the target test requirement includes an identifier of the target test requirement, a title of the target test requirement, and content of the target test requirement. The identifier of the target test requirement is used to identify the target test requirement among multiple test requirements, and the title of the target test requirement is used to briefly describe the content of the target test requirement. The method further includes: in response to a second operation on the area where the target test requirement is located, displaying a first sub-mind map, the first sub-mind map including the identifier of the target test requirement and the title of the target test requirement, the title of the target test requirement being a root node, the title of the target test requirement being a first child node, and the first child node being connected to the root node.
[0010] In one possible implementation, the method further includes: upon receiving the test function point output by the large model and the test function point does not carry indication information, updating the first sub-mind map to obtain a second sub-mind map, wherein the indication information is used to indicate that the output result of the large model is abnormal, the second sub-mind map includes the first sub-mind map and the test function point, the test function point being a second sub-node, and the second sub-node being connected to the first sub-node; upon receiving the test case design output by the large model and the test case design not carrying the indication information, updating the second sub-mind map to obtain a third sub-mind map, the third sub-mind map including the second sub-mind map and the test case design, the test case design being a third sub-node, and the third sub-node being connected to the second sub-node; upon receiving the test case output by the large model and the test case not carrying the indication information, updating the third sub-mind map to obtain a fourth sub-mind map, the fourth sub-mind map including the third sub-mind map and the test case, the test case being a fourth sub-node, and the fourth sub-node being connected to the third sub-node.
[0011] In one possible implementation, the method further includes: upon receiving the test case output by the large model carrying the indication information, updating the third sub-mind map to obtain a fifth sub-mind map, wherein the fifth mind map includes the third mind map and an anomaly node, and the anomaly node is used to indicate that the test case is abnormal.
[0012] In one possible implementation, the method further includes: displaying pop-up information when the duration of the third operation on the area where the target test requirement is located is greater than a preset duration, the pop-up information including the identifier of the target test requirement, the title of the target test requirement, and the content of the target test requirement; or, displaying the pop-up information when the duration of the third operation on a node in the first mind map is greater than the preset duration.
[0013] Secondly, this application provides a test case generation device, the device comprising: an acquisition module for acquiring target test requirements; a prompt word generation module for generating a first prompt word based on the target test requirements and a first preset content, the first preset content being used to provide a basis for generating a function point to be tested; an input module for inputting the first prompt word into a large model for reasoning to obtain the function point to be tested corresponding to the target test requirements; the prompt word generation module for generating a second prompt word based on the target test requirements, the function point to be tested, and a second preset content, the second preset content being used to provide a basis for generating test case designs; the input module for inputting the second prompt word into the large model for reasoning to obtain a test case design corresponding to the function point to be tested; the prompt word generation module for generating a third prompt word based on the target test requirements, the function point to be tested, the test case design, and a third preset content, the third preset content being used to provide a basis for generating test cases; and the input module for inputting the third prompt word into the large model for reasoning to obtain test cases corresponding to the test case design.
[0014] In one possible implementation, the prompt word generation module is specifically used to calculate multiple cosine similarities between the content of the target testing requirement and multiple pieces of preset content in a preset vector library, each cosine similarity being obtained based on the content of the target testing requirement and a piece of preset content; determining at least one piece of preset content as the first preset content in the preset vector library based on the multiple cosine similarities; and generating a first prompt word based on the content of the target testing requirement and the first preset content.
[0015] In one possible implementation, the acquisition module is specifically configured to acquire a test requirement file, the test requirement file including at least one test requirement; display the at least one test requirement in a first area; and, in response to a first operation on the area where the target test requirement is located, determine the target test requirement from among the at least one test requirement.
[0016] In one possible implementation, the apparatus further includes: a first display module, configured to display a first sub-mind map in response to a second operation on the area where the target test requirement is located, the first sub-mind map including an identifier of the target test requirement and a title of the target test requirement, the title of the target test requirement being a root node, the title of the target test requirement being a first child node, and the first child node being connected to the root node.
[0017] In one possible implementation, the apparatus further includes: a first update module, configured to update the first sub-mind map to obtain a second sub-mind map when the test function point output by the large model is received and the test function point does not carry indication information; the indication information is used to indicate that the output result of the large model is abnormal; the second sub-mind map includes the first sub-mind map and the test function point, the test function point being a second sub-node, and the second sub-node being connected to the first sub-node; and when the test case design output by the large model is received and the test case design does not carry the indication information... In the event of receiving the test case from the large model, the second sub-mind map is updated to obtain a third sub-mind map. The third sub-mind map includes the second sub-mind map and the test case design, where the test case design is a third sub-node connected to the second sub-node. Upon receiving the test case output by the large model, and if the test case does not carry the instruction information, the third sub-mind map is updated to obtain a fourth sub-mind map. The fourth sub-mind map includes the third sub-mind map and the test case, where the test case is a fourth sub-node connected to the third sub-node.
[0018] In one possible implementation, the apparatus further includes: a second update module, configured to update the third sub-mind map to obtain a fifth sub-mind map upon receiving the test case output by the large model carrying the indication information, the fifth mind map including the third mind map and an anomaly node, the anomaly node being used to indicate an anomaly in the test case.
[0019] In one possible implementation, the device further includes: a second display module, configured to display pop-up information when the duration of a third operation on the area where the target test requirement is located exceeds a preset duration, the pop-up information including the identifier of the target test requirement, the title of the target test requirement, and the content of the target test requirement; or, to display the pop-up information when the duration of the third operation on a node in the first mind map exceeds the preset duration.
[0020] Thirdly, this application provides a computer device including a processor and a memory, the memory being used to store instructions, and the processor executing the instructions stored in the memory to cause the computer device to perform any of the test case generation methods described above.
[0021] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the test case generation method described in any one of the claims.
[0022] Based on the implementation methods provided in the above aspects, this application can be further combined to provide more implementation methods.
[0023] As can be seen from the above technical solutions, this application has the following beneficial effects:
[0024] The test case generation tool can acquire target test requirements and generate first prompts based on these requirements and a first set of preset content used to generate the functionalities to be tested. Then, the tool inputs these prompts into a large model for reasoning, resulting in the functionalities to be tested corresponding to the target test requirements. Further, the tool can generate second prompts based on the target test requirements, the functionalities to be tested, and a second set of preset content used to generate test case designs. These second prompts are then input into the large model for reasoning, resulting in the test case designs corresponding to the functionalities to be tested. Finally, the tool can generate third prompts based on the target test requirements, the functionalities to be tested, the test case designs, and a third set of preset content used to generate test cases. These third prompts are then input into the large model for reasoning, resulting in the test cases corresponding to the test case designs. In this way, the test case generation tool can analyze the target test requirements using a large model, improving the comprehensiveness of the analysis compared to testers analyzing the target test requirements themselves. Consequently, test cases generated by the test case generation tool using the large model have higher functional coverage than test cases written by testers. Furthermore, test case generation tools can improve the efficiency of test case generation by using large models to generate test cases compared to testers writing test cases. Attached Figure Description
[0025] Figure 1 This is a flowchart illustrating a test case generation method provided in an embodiment of this application;
[0026] Figure 2 A schematic diagram of a test case generation tool provided in this application, which displays each test requirement in the first area.
[0027] Figure 3 A schematic diagram of a first mind map provided in an embodiment of this application;
[0028] Figure 4 A schematic diagram of a second mind map provided in an embodiment of this application;
[0029] Figure 5 A schematic diagram of a third mind map provided in an embodiment of this application;
[0030] Figure 6 A schematic diagram of a fourth mind map provided in an embodiment of this application;
[0031] Figure 7 This is a schematic diagram illustrating the display of pop-up information provided in an embodiment of this application;
[0032] Figure 8 This is a schematic diagram of a test case generation device provided in an embodiment of this application. Detailed Implementation
[0033] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate; this is merely a method of distinction used in describing objects with the same attributes in the embodiments of this application.
[0034] To make the above-mentioned objectives, features and advantages of the embodiments of this application more apparent and understandable, the embodiments of this application will be further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0035] During product development, errors are inevitable. Therefore, after product development is complete, testers typically need to test the product to prevent losses caused by defective products being put into practical use. For example, testers usually test nuclear power plant instrumentation and control system software products after development is finished.
[0036] Currently, after receiving the test requirements document, testers analyze the test requirements within it and extract the functionalities to be tested from the software product under test based on the test requirements and design information. Then, based on the analyzed functionalities to be tested, testers design test cases and write the corresponding test cases, thus completing the test case writing process.
[0037] However, the test cases generated using this method have low functional coverage. Furthermore, this method is relatively inefficient in generating test cases.
[0038] Based on this, embodiments of this application provide a method for generating test cases using a large model, so as to improve the functional coverage of test cases and improve the efficiency of test case generation.
[0039] In practical implementation, the test case generation tool can acquire the target test requirements and generate a first prompt word based on these requirements and a first preset content used to provide a basis for generating the functional points to be tested. Then, the test case generation tool can input the first prompt word into a large model for reasoning to obtain the functional points to be tested corresponding to the target test requirements. Further, the test case generation tool can generate a second prompt word based on the target test requirements, the functional points to be tested, and a second preset content used to provide a basis for generating test case designs, and input the second prompt word into the large model for reasoning to obtain the test case designs corresponding to the functional points to be tested. Finally, the test case generation tool can generate a third prompt word based on the target test requirements, the functional points to be tested, the test case designs, and a third preset content used to provide a basis for generating test cases, and input the third prompt word into the large model for reasoning to obtain the test cases corresponding to the test case designs. In this way, the test case generation tool can analyze the target test requirements using a large model, which improves the comprehensiveness of the analysis compared to testers analyzing the target test requirements themselves. Therefore, test cases generated by the test case generation tool using a large model have higher functional coverage than test cases written by testers. Furthermore, test case generation tools can improve the efficiency of test case generation by using large models to generate test cases compared to testers writing test cases.
[0040] To facilitate understanding of the embodiments of this application, a test case generation method provided by the embodiments of this application will be described below with reference to the accompanying drawings.
[0041] See Figure 1 , Figure 1 This is a flowchart illustrating a test case generation method provided in an embodiment of this application.
[0042] in, Figure 1 The test case generation method shown may specifically include the following steps.
[0043] S101: The test case generation tool obtains the target test requirements.
[0044] In practice, testers first import test requirement files into the test case generation tool. These files can contain at least one test requirement. Each test requirement includes an identifier, a title, and content. The identifier uniquely identifies the test requirement from among multiple requirements. The title briefly describes its content.
[0045] In one possible implementation, the identifier for a test requirement can be set as "Software Requirements Specification (SRS) - Function Name - Function Identifier". For example, the identifier for a test requirement could be "SRS-PATENT-145", where PATENT is the name of the function and 145 is the function identifier.
[0046] In one possible implementation, each test requirement in the test requirement document is arranged in an itemized manner and presented in a title format.
[0047] Furthermore, in response to the tester's import action, the test case generation tool can read the test requirement file.
[0048] Specifically, the test case generation tool scans each line of the test requirement file line by line and extracts each requirement using regular expressions. For example, the tool might identify a test requirement by the middle portion of "SRS-Function Name-Function Identifier" appearing twice. Then, the tool can assign hierarchy among the requirements according to their heading levels, creating a mind map. This mind map can include the test requirement identifier, the test requirement title, and the test requirement content. The title and content can be sub-elements of the test requirement identifier. Furthermore, the mind map can be in JSON format.
[0049] Furthermore, the test case generation tool can display each test requirement in a tree-like list format in the first area. This first area can be the requirement interface of the test case generation tool. In one example, the test case generation tool can display the identifier and title of each test requirement in the first area, for example, displaying each test requirement as "Test Requirement Identifier - Test Requirement Title".
[0050] See Figure 2 , Figure 2 A schematic diagram of a test case generation tool is shown, displaying each test requirement in the first area.
[0051] Testers can identify a target test requirement from multiple test requirements and perform a first action on the area containing the target test requirement. This first action could be, for example, a click. In response to the tester's first action on the area containing the target test requirement, the test case generation system can obtain the identifier and title of the target test requirement.
[0052] S102: The test case generation tool generates a first prompt word based on the target test requirements and the first preset content. The first preset content is used to provide a basis for the generation of the function points to be tested.
[0053] The test case generation tool stores multiple preset contents in a local preset vector library.
[0054] In one possible implementation, testers can input a preset file into an embedding model, which can divide the preset file into multiple preset content blocks according to the format of title and content. The embedding model can convert the text content into vector format. Then, the embedding model can vectorize each preset content block and store the vectorized preset content blocks in a local preset vector library. The preset file can be, for example, a user manual for the software under test, or the architectural principles of the software under test.
[0055] The test case generation tool can calculate multiple cosine similarities between the content of the target test requirement and multiple preset content blocks in a preset vector library. Each cosine similarity is obtained based on the content of the target test requirement and a preset content block.
[0056] Specifically, after obtaining the identifier of the target test requirement, the test case generation tool can extract the content of the target test requirement from the mind map file based on the identifier. Then, the test case generation tool can use an embedding model to transform the content of the target test requirement into a high-dimensional vector. Further, the test case generation tool can calculate the cosine similarity between the content of the target test requirement and each preset content in the vector database using the following formula:
[0057] ;
[0058] in, For cosine similarity, The content of the vectorized target test. This is the preset content for vectorization, where n is the dimension of the vector.
[0059] Furthermore, the test case generation tool can determine at least one preset content corresponding to a cosine similarity score as the first preset content, in descending order of cosine similarity. Then, the test case generation tool can generate a first prompt word based on the content of the target test requirement and the first preset content. The first prompt word can include both the content of the target test requirement and the first preset content.
[0060] S103: The test case generation tool inputs the first prompt word into the large model for reasoning to obtain the functional points to be tested corresponding to the target test requirements.
[0061] The test case generation tool can input the first prompt word into the large model. The large model can infer from the first prompt word to obtain the functional point to be tested corresponding to the target test requirement. Then, the large model can send the first data segment to the test case generation tool. The first data segment can include the content of the target test requirement and the functional point to be tested, with the functional point to be tested serving as a sub-element of the target test requirement content. The functional point to be tested can include a title and content. The title can briefly describe the content, while the content describes the specific function or behavioral scenario to be verified. In one example, the first data segment can be in JSON format.
[0062] It should be noted that large-scale models refer to machine learning models with a large number of parameters and complex computational structures. They learn language rules and world knowledge through massive amounts of parameters to achieve natural language understanding, generation, reasoning, and multimodal processing. Large-scale models can answer questions, create text, write code, and translate summaries. As a general artificial intelligence infrastructure, they deeply empower education, scientific research, office work, programming, and other fields, significantly improving the efficiency of human-computer interaction and knowledge acquisition.
[0063] S104: The test case generation tool generates a second prompt word based on the target test requirements, the functional points to be tested, and the second preset content. The second preset content is used to provide a basis for the generation of test case design.
[0064] After obtaining the test function points from the large model output, the test case generation tool can generate the first target content. The first target content can include the content of the target test requirements and the content of the test function points. Then, the test case generation tool can calculate multiple cosine similarities between the first target content and multiple preset content blocks in the vector database. Each cosine similarity is obtained based on the first target content and a preset content block. The calculation process for the multiple cosine similarities between the first target content and the multiple preset content blocks in the vector database is the same as the calculation process for the multiple cosine similarities between the target test requirements and the multiple preset content blocks in the preset vector library; therefore, the repetitions will not be repeated.
[0065] Furthermore, the test case generation tool can determine at least one preset content corresponding to a cosine similarity score as the second preset content, in descending order of cosine similarity. Then, the test case generation tool can generate a second prompt word based on the first target content and the second preset content. The second prompt word can include the content of the target test requirement, the content of the function point to be tested, and the second preset content.
[0066] S105: The test case generation tool inputs the second prompt word into the large model for reasoning, and obtains the test case design corresponding to the function point to be tested.
[0067] The test case generation tool can input a second prompt word into the large model. The large model can reason about the second prompt word to obtain the test case design corresponding to the function to be tested. Then, the large model can send a second data segment to the test case generation tool. This second data segment can include the function to be tested and the test case design, with the test case design serving as a sub-element of the function to be tested. The test case design can include a title and content. The title can briefly describe the content, while the content can describe the steps for testing the function, the data to be tested, and the preset test results. In one example, the second data segment can be in JSON format.
[0068] S106: The test case generation tool generates a third prompt word based on the target test requirements, the function to be tested, the test case design, and the third preset content. The third preset content is used to provide a basis for the generation of test cases.
[0069] After obtaining the test case design from the large model, the test case generation tool can generate second target content. This second target content can include the content of the target test requirements, the content of the functional points to be tested, and the content of the test case design. Then, the test case generation tool can calculate multiple cosine similarities between the second target content and multiple preset content blocks in the vector database. Each cosine similarity is obtained based on the second target content and a preset content block. The calculation process for the multiple cosine similarities between the second target content and the multiple preset content blocks in the vector database is the same as the calculation process for the multiple cosine similarities between the target test requirements and the multiple preset content blocks in the preset vector library; therefore, the repetitions will not be repeated.
[0070] Furthermore, the test case generation tool can determine at least one preset content corresponding to a cosine similarity score as the third preset content, in descending order of cosine similarity. Then, the test case generation tool can generate a third prompt word based on the second target content and the third preset content. The third prompt word can include the content of the target test requirement, the content of the function point to be tested, and the third preset content.
[0071] S107: The test case generation tool inputs the third prompt word into the large model for reasoning and obtains the test cases corresponding to the test case design.
[0072] The test case generation tool can input third-party prompts into a large model. The large model can reason about the third-party prompts to generate test cases corresponding to the test case design. Then, the large model can send a third data segment to the test case generation tool. This third data segment can include the test case design and the test cases themselves, with the test cases serving as sub-elements of the test case design. Each test case can include a title and data. The title can briefly describe the test case data, and the data can be used to test the functionality of the software under test. In one example, the third data segment can be in JSON format.
[0073] Through the method provided in the above embodiments, the test case generation tool can obtain the target test requirements and generate a first prompt word based on the target test requirements and a first preset content used to provide a basis for generating the function points to be tested. Then, the test case generation tool can input the first prompt word into a large model for reasoning to obtain the function points to be tested corresponding to the target test requirements. Further, the test case generation tool can generate a second prompt word based on the target test requirements, the function points to be tested, and a second preset content used to provide a basis for generating test case designs, and input the second prompt word into the large model for reasoning to obtain the test case design corresponding to the function points to be tested. Finally, the test case generation tool can generate a third prompt word based on the target test requirements, the function points to be tested, the test case design, and a third preset content used to provide a basis for generating test cases, and input the third prompt word into the large model for reasoning to obtain the test cases corresponding to the test case design. In this way, the test case generation tool can use a large model to analyze the target test requirements, which improves the comprehensiveness of the target test requirement analysis compared to testers analyzing the target test requirements themselves. Therefore, the test cases generated by the test case generation tool using the large model have higher functional coverage than test cases written by testers. Furthermore, test case generation tools can improve the efficiency of test case generation by using large models to generate test cases compared to testers writing test cases.
[0074] In one possible implementation, the target test requirement may include an identifier for the target test requirement, a title for the target test requirement, and content for the target test requirement. The identifier for the target test requirement can be used to identify the target test requirement among multiple test requirements, and the title of the target test requirement can be used to briefly describe the content of the target test requirement. Testers can perform a second operation on the area containing the target test requirement within the first area. This second operation may be, for example, a click operation. In response to the tester's second operation on the area containing the target test requirement, the test case generation tool can display a first sub-mind map on its mind map interface. This first sub-mind map may include the identifier for the target test requirement and a title for the target test requirement. The title of the target test requirement can be the root node, and the title of the target test requirement can be a first child node, which can be connected to the root node.
[0075] See Figure 3 , Figure 3 A schematic diagram of a first sub-mind map is shown.
[0076] In one possible implementation, when the test case generation tool receives the functional point to be tested from the output of the large model, and the functional point to be tested does not carry indication information, it can update the first sub-mind map to obtain a second sub-mind map. The indication information can be used to indicate anomalies in the output of the large model. The second sub-mind map can include the first sub-mind map and the functional point to be tested. The functional point to be tested can be the second root node, and the second node can be connected to the first node.
[0077] See Figure 4 , Figure 4 This diagram illustrates a second sub-mind map.
[0078] Furthermore, when the test case generation tool receives the test case design output from the large model and the test case design does not carry instruction information, it can update the second sub-mind map to obtain a third sub-mind map. The third sub-mind map can include the second sub-mind map and the test case design, where the test case design can be a third child node, and the third child node can be connected to the second child node.
[0079] See Figure 5 , Figure 5 This diagram illustrates a third sub-mind map.
[0080] When the test case generation tool receives test cases from the large model output without carrying instruction information, it updates the third sub-mind map to obtain the fourth sub-mind map. The fourth sub-mind map can include the third sub-mind map and test cases. Test cases can be fourth child nodes, and fourth child nodes can be connected to third child nodes.
[0081] See Figure 6 , Figure 6 A schematic diagram of a fourth sub-mind map is shown.
[0082] In one possible implementation, upon receiving test cases with indication information output from the large model, the test case generation tool updates the third sub-mind map to obtain a fifth sub-mind map. The fifth sub-mind map includes the third sub-mind map and exception nodes, which indicate test case exceptions. These exception nodes can be highlighted to alert testers when exceptions occur.
[0083] Understandably, when a test case generation tool receives instruction information from a function to be tested or a test case design, it will not display the function to be tested or the test case design, but will instead display the exception node.
[0084] In one possible implementation, if the duration of a tester's third action on the area containing the target test requirement exceeds a preset duration, the test case generation tool can display a pop-up message. This third action, for example, is the mouse hovering over the area containing the target requirement. The pop-up message can include the identifier of the target test requirement, its title, and its content.
[0085] In one possible implementation, if the duration of the third operation on a node in the first mind map exceeds a preset duration, the test case generation tool may display a pop-up message.
[0086] See Figure 7 The diagram illustrates a pop-up window display for a test case generation tool.
[0087] In one possible implementation, all nodes in the mind map are editable. Testers can supplement the functionalities to be tested, test case designs, and test cases generated from the large model.
[0088] In one possible implementation, the test case generation tool mainly uses Python and PyQt5 to generate test cases.
[0089] It is worth noting that other reasonable combinations of steps that can be conceived by those skilled in the art based on the above description also fall within the scope of protection of this application. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to this application.
[0090] Based on the test case generation method provided in the above-described embodiments, this application also provides a test case generation device, which will be described below with reference to the accompanying drawings. Since the principle by which the device in this disclosure solves the problem is similar to the test case generation method described above in this application, the implementation of the device can refer to the implementation of the method, and repeated details will not be elaborated further.
[0091] See Figure 8 As shown in the figure, this is a schematic diagram of the structure of a test case generation device provided in an embodiment of this application. Figure 8 As shown, the test case generation device 800 includes:
[0092] Module 801 is used to obtain the target test requirements;
[0093] The prompt word generation module 802 is used to generate a first prompt word based on the target test requirements and a first preset content. The first preset content is used to provide a basis for the generation of the function point to be tested.
[0094] The input module 803 is used to input the first prompt word into the large model for inference to obtain the functional points to be tested corresponding to the target test requirements;
[0095] The prompt word generation module 802 is used to generate a second prompt word based on the target test requirements, the function point to be tested, and the second preset content. The second preset content is used to provide a basis for the generation of test case design.
[0096] Input module 803 is used to input the second prompt word into the large model for reasoning to obtain the test case design corresponding to the function point to be tested;
[0097] The prompt word generation module 802 is used to generate a third prompt word based on the target test requirements, the function point to be tested, the test case design, and the third preset content. The third preset content is used to provide a basis for the generation of test cases.
[0098] The input module 803 is used to input the third prompt word into the large model for reasoning and to obtain the test cases corresponding to the test case design.
[0099] In one possible implementation, the prompt word generation module 802 is specifically used to calculate multiple cosine similarities between the content of the target test requirement and multiple pieces of preset content in a preset vector library, wherein each cosine similarity is obtained based on the content of the target test requirement and a piece of preset content.
[0100] Based on multiple cosine similarities, at least one piece of preset content is determined in the preset vector library as the first preset content;
[0101] The first prompt word is generated based on the content of the target test requirements and the first preset content.
[0102] In one possible implementation, the acquisition module 801 is specifically used to acquire a test requirement file, which includes at least one test requirement.
[0103] Display at least one test requirement in the first area;
[0104] In response to the first operation on the area where the target test requirement is located, the target test requirement is identified in at least one test requirement.
[0105] In one possible implementation, the test case generation device 800 further includes:
[0106] The first display module is used to respond to the second operation on the area where the target test requirement is located, and to display the first sub-mind map. The first sub-mind map includes the identifier of the target test requirement and the title of the target test requirement. The title of the target test requirement is the root node, the title of the target test requirement is the first child node, and the first child node is connected to the root node.
[0107] In one possible implementation, the test case generation apparatus further includes:
[0108] The first update module is used to update the first sub-mind map and obtain the second sub-mind map when the test function point is received from the output of the large model and the test function point does not carry indication information. The indication information is used to indicate that the output result of the large model is abnormal. The second sub-mind map includes the first sub-mind map and the test function point. The test function point is the second sub-node, and the second sub-node is connected to the first sub-node.
[0109] When the test case design is received from the output of the large model and the test case design does not carry instruction information, the second sub-mind map is updated to obtain the third sub-mind map. The third sub-mind map includes the second sub-mind map and the test case design. The test case design is the third sub-node, and the third sub-node is connected to the second sub-node.
[0110] When the test cases output by the large model are received and the test cases do not carry instruction information, the third sub-mind map is updated to obtain the fourth sub-mind map. The fourth sub-mind map includes the third sub-mind map and the test cases. The test cases are the fourth sub-nodes, and the fourth sub-nodes are connected to the third sub-nodes.
[0111] In one possible implementation, the test case generation apparatus further includes:
[0112] The second update module is used to update the third sub-mind map and obtain the fifth sub-mind map when the test cases output by the large model carry indication information. The fifth mind map includes the third mind map and the exception node, which is used to indicate the exception of the test case.
[0113] In one possible implementation, the test case generation apparatus further includes:
[0114] The second display module is used to display pop-up information when the duration of the third operation on the area where the target test requirement is located exceeds the preset duration. The pop-up information includes the identifier of the target test requirement, the title of the target test requirement, and the content of the target test requirement.
[0115] Alternatively, if the duration of the third operation on a node in the first mind map exceeds the preset duration, a pop-up message will be displayed.
[0116] It should be noted that the specific implementation of each module in this embodiment can be found in the relevant descriptions in the above method embodiments. The module division in this application embodiment is illustrative and only represents a logical functional division; in actual implementation, there may be other division methods. In this application embodiment, each functional module can be concentrated in one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. For example, in the above embodiment, the first acquisition module and the holding module can be the same module or different modules.
[0117] In addition, this application also provides a computer device, which includes a processor and a memory. The memory is used to store instructions, and the processor executes the instructions stored in the memory to cause the computer device to perform the test case generation method provided in any of the above embodiments.
[0118] This application also provides a computer-readable storage medium storing a computer program thereon, wherein the program, when executed by a processor, implements the test case generation method provided in any of the above embodiments.
[0119] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems or apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section.
[0120] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0121] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0122] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0123] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A test case generation method characterized by, The method includes: Obtain the target testing requirements; A first prompt word is generated based on the target test requirements and the first preset content, wherein the first preset content is used to provide a basis for the generation of the function point to be tested; The first prompt word is input into the large model for inference to obtain the functional points to be tested corresponding to the target test requirements; A second prompt word is generated based on the target test requirements, the functional points to be tested, and the second preset content. The second preset content is used to provide a basis for the generation of test case design. The second prompt word is input into the large model for reasoning to obtain the test case design corresponding to the function point to be tested; A third prompt word is generated based on the target test requirements, the function points to be tested, the test case design, and the third preset content. The third preset content is used to provide a basis for the generation of test cases. The third prompt word is input into the large model for reasoning to obtain the test cases corresponding to the test case design.
2. The method of claim 1, wherein, The target test requirements include the content of the target test requirements; The step of generating the first prompt word based on the target testing requirements and the first preset content includes: Calculate multiple cosine similarities between the content of the target test requirement and multiple pieces of preset content in the preset vector library. Each cosine similarity is obtained based on the content of the target test requirement and a piece of preset content. Based on the multiple cosine similarities, at least one piece of preset content is determined in the preset vector library as the first preset content; A first prompt word is generated based on the content of the target test requirements and the first preset content.
3. The method of claim 1, wherein, The acquisition of target test requirements includes: Obtain the test requirement document, which includes at least one test requirement; Display at least one of the test requirements in the first area; In response to a first operation on the region where the target test requirement is located, the target test requirement is determined from the at least one test requirement.
4. The method of claim 3, wherein, The target test requirement includes an identifier, a title, and content. The identifier is used to identify the target test requirement among multiple test requirements, and the title is used to briefly describe the content. The method further includes: In response to a second operation on the area where the target test requirement is located, a first sub-mind map is displayed. The first sub-mind map includes an identifier for the target test requirement and a title for the target test requirement. The title of the target test requirement is the root node, and the title of the target test requirement is the first child node, which is connected to the root node.
5. The method of claim 4, wherein, The method further includes: When the test function point is received from the output of the large model and the test function point does not carry indication information, the first sub-mind map is updated to obtain the second sub-mind map. The indication information is used to indicate that the output result of the large model is abnormal. The second sub-mind map includes the first sub-mind map and the test function point. The test function point is a second sub-node, and the second sub-node is connected to the first sub-node. Upon receiving the test case design output by the large model, and if the test case design does not carry the instruction information, the second sub-mind map is updated to obtain a third sub-mind map. The third sub-mind map includes the second sub-mind map and the test case design, with the test case design being a third sub-node, and the third sub-node being connected to the second sub-node. If the test case output by the large model is received and the test case does not carry the instruction information, the third sub-mind map is updated to obtain a fourth sub-mind map. The fourth sub-mind map includes the third sub-mind map and the test case. The test case is a fourth sub-node, and the fourth sub-node is connected to the third sub-node.
6. The method of claim 5, wherein, The method further includes: Upon receiving the test case output by the large model carrying the indication information, the third sub-mind map is updated to obtain the fifth sub-mind map. The fifth mind map includes the third mind map and an exception node, which is used to indicate that the test case is abnormal.
7. The method of claim 3, wherein, The method further includes: If the duration of the third operation on the area where the target test requirement is located exceeds a preset duration, a pop-up window will be displayed. The pop-up window includes the identifier of the target test requirement, the title of the target test requirement, and the content of the target test requirement. Alternatively, if the duration of the third operation on a node in the first mind map exceeds the preset duration, the pop-up information will be displayed.
8. A test case generation apparatus characterized by comprising: The device includes: The acquisition module is used to acquire the target test requirements; The prompt word generation module is used to generate a first prompt word based on the target test requirements and a first preset content, wherein the first preset content is used to provide a basis for the generation of the function point to be tested. The input module is used to input the first prompt word into the large model for reasoning to obtain the functional point to be tested corresponding to the target test requirement; The prompt word generation module is used to generate a second prompt word based on the target test requirements, the function point to be tested, and the second preset content. The second preset content is used to provide a basis for the generation of test case design. The input module is used to input the second prompt word into the large model for reasoning to obtain the test case design corresponding to the function point to be tested; The prompt word generation module is used to generate a third prompt word based on the target test requirements, the function point to be tested, the test case design, and the third preset content. The third preset content is used to provide a basis for the generation of test cases. The input module is used to input the third prompt word into the large model for reasoning to obtain the test cases corresponding to the test case design.
9. A computer device, comprising: The computer device includes a processor and a memory, the memory being used to store instructions, the processor executing the instructions stored in the memory to cause the computer device to perform the test case generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores a computer program, wherein the computer program, when executed by a processor, implements the test case generation method as described in any one of claims 1 to 7.