Test case generation method based on large model

By applying large models and knowledge graphs during the software testing process, and automatically generating test cases and scripts, the problems of low testing efficiency and high cost caused by manual intervention are solved, and more efficient and economical software testing is achieved.

CN120029917APending Publication Date: 2025-05-23SU ZHOU FENG HE SHI XIN XIN XI KE JI YOU XIAN GONG SI
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510126050.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-27
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In the prior art, there is a lot of manual intervention in the software testing process, resulting in low testing efficiency and high cost, and it is unable to meet the current demand for rapid release.

Method used

Using a test case generation method based on large models, we will automate software requirements modeling, test script generation and coverage path generation by building test cases based on large models and knowledge graphs to reduce manual intervention.

Benefits of technology

It reduces the cost of software testing, improves testing efficiency, realizes automation of the testing process, and ensures improvement of software quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029917A_ABST
    Figure CN120029917A_ABST
Patent Text Reader

Abstract

The invention discloses a test case generation method based on a large model, and belongs to the technical field of large models, and the method comprises the steps: respectively constructing test cases based on the large model and a knowledge graph, and generating a system scheme according to the constructed test cases; modeling is carried out according to software requirements, and the modeling process comprises software requirement modeling, test intention statement recognition, test requirement content ontology construction, test condition entity attribute extraction and generated test case traversal and query functions; generating a test script based on the large model, and automatically generating a script code conforming to the test logic in combination with the demand model and the test intention; and performing test knowledge graph reasoning. In the implementation process of the technical scheme, the large model and the knowledge graph are applied to the software testing process, the links of test case generation, demand modeling, test script generation and the like are covered, manual intervention in the software testing process is reduced, the software testing cost is reduced, and the testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of large model technology, and specifically to a test case generation method based on a large model. Background Art

[0002] In software testing, requirement-based testing is an important link. During the testing process, it is verified whether the software requirements are met according to the completion standards, test cases and other requirements.

[0003] In the prior art, demand-based testing designs multiple manual processes, in which software testers must define test completion criteria, design test cases from requirements, build test cases, execute test cases, and verify whether software requirements are met. If the demand-based testing process cannot run normally, the number of test cases is large and the test cannot be completed within a reasonable time, or the test cases cannot obtain the expected results. Therefore, traditional testing methods have been unable to meet current needs.

[0004] In recent years, with the development of technologies such as knowledge graphs and big models, applying these technologies to the software testing process can not only reduce costs, but also shorten the product release cycle, improve the efficiency of software development, and automate the testing process. Therefore, how to apply these technologies to the software testing process is an issue that needs to be solved urgently.

[0005] Therefore, it is necessary to provide a test case generation method based on a large model to solve the above problems.

[0006] It should be noted that the above information disclosed in this background technology section is only for understanding the background technology of the present application concept, and therefore, it may contain information that does not constitute the prior art. Summary of the invention

[0007] Based on the above problems existing in the prior art, the problem to be solved by this application is: to provide a test case generation method based on a large model, by integrating the application of the large model, reducing the manual intervention in the software testing process and improving the software testing efficiency.

[0008] The technical solution adopted by the present application to solve the technical problem is: a test case generation method based on a large model, characterized in that: the method comprises: Build test cases based on big models and knowledge graphs respectively, and generate system solutions based on the built test cases; Modeling is performed according to software requirements. The modeling process includes software requirement modeling, test intent statement recognition, test requirement content ontology construction, test condition entity attribute extraction, and test case traversal and query function generation; Generate test scripts based on large models, combine demand models and test intent, automatically generate script code that conforms to test logic, and verify script validity through simulation execution; Test knowledge graph reasoning, use the relationship between test entities and the reasoning pattern between relationship paths to generate semantic relationship calculations, and use knowledge graph path test traversal technology to generate coverage paths.

[0009] During the implementation of the technical solution of this application, by applying large models and knowledge graphs to the software testing process, covering test case generation, requirement modeling, test script generation and other links, human intervention in the software testing process is reduced, software testing costs are reduced, and testing efficiency is improved.

[0010] Furthermore, the construction of test cases based on the large model includes the following steps: According to the software functional requirements, use the big model to analyze user behavior and generate diversified test scenarios; collect software historical data, and perform intelligent analysis on the historical data to identify potential risk points, and then perform data preprocessing; select at least one test case template, and fill in the test case content in combination with the scenarios generated by the big model and the historical data analysis results; verify and optimize the filled test cases, and optimize the construction process based on the verification results. After the optimization is completed, update the historical data.

[0011] Furthermore, the filled test cases are verified and optimized using a combination of automated testing tools or manual review to verify the coverage and accuracy of the test cases.

[0012] Furthermore, the test intent sentence recognition uses the Bert model for semantic analysis, and the declaration of the requirement content is input into the model for keyword extraction. Combined with the pre-trained Bert model, the embedded representation of the sentence is obtained, and then the deep learning-based text classification algorithm TextCNN is used to classify the text content, identify sentences with test intent and test requirements, and filter out irrelevant sentences.

[0013] Furthermore, the construction of the test requirement content ontology includes: performing sentence pass and component analysis on the statements with test intentions and test requirements in the requirement content to obtain the components of the test requirement content; obtaining the input combination of the test requirement statement test as the precondition entity, the test result as the postcondition entity, the intermediate precondition and postcondition entities are used to connect between the precondition and the postcondition, and the action entity is used to connect the adopted action steps.

[0014] Furthermore, the test condition entity attribute extraction includes identifying the entity type and its attributes. For the entity attribute extraction of the pre- and post-condition entities, NER entity recognition and relationship extraction are used to identify the test variable type and the type of logical operation in the input conditions, and to identify the test unit and recursive structure.

[0015] Furthermore, according to the type of test unit and structure, the test expert's experience and test requirements on the test type are obtained, the scope and boundary conditions of the test are designed, and then the equivalence class is expanded and filled with default values.

[0016] Furthermore, during the reasoning process, the knowledge graph path test traversal technique is used and implemented using the key point path representation.

[0017] Furthermore, the key point path representation includes the definition of entry key points and exit key points, the entry key point is the entry node of the control flow graph, and the exit key point is the exit node of the control flow graph; the branch key node, which is the description of the program branch by the control flow graph, is a branch node with two direct successor nodes; the branch key point is decomposed from the loop node in the control flow graph.

[0018] The beneficial effect of the present application is that the present application provides a test case generation method based on a big model, which covers test case generation, requirement modeling, test script generation and other links by applying the big model and knowledge graph to the software testing process, thereby reducing manual intervention in the software testing process, reducing software testing costs and improving testing efficiency.

[0019] In addition to the above-described purposes, features and advantages, the present application also has other purposes, features and advantages. The present application will be further described in detail with reference to the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 The figure is a schematic diagram of the overall process of a test case generation method based on a large model in this application. DETAILED DESCRIPTION

[0021] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0023] like Figure 1 As shown, the present application provides a test case generation method based on a large model, which is used in software testing and combines the advantages of a large model to automatically generate efficient and comprehensive test cases, improve test efficiency and accuracy, and ensure software quality. Specifically, the test case generation method includes: Step 10: Build test cases based on the big model and knowledge graph respectively, and generate system solutions based on the built test cases; In the software testing process, it is necessary to consider different scenarios and user needs, build multiple test cases, and then generate a system solution based on the built test cases. A test case refers to a set of test inputs, execution conditions, and expected results compiled for a specific goal, which is used to verify whether a specific software requirement is met. In this embodiment, different categories of test cases are built respectively by combining the big model and the knowledge graph to generate a system solution. The test case construction based on the big model includes the following steps: Step 101: Analyze user behavior using a large model and generate diverse test scenarios based on software functional requirements; In the software testing process, different software has different functional requirements, and different software corresponds to different user groups. Therefore, in the traditional software testing process, it is difficult to generate diversified test scenarios based on user behavior, resulting in test results that are not in line with the actual needs of the software. Therefore, in this embodiment, after analyzing user behavior based on software functional requirements in combination with a large model, a variety of test scenarios are generated. Among them, the large model can select the current mainstream large model such as GPT-4, etc., which is not limited in this embodiment; Step 102: Collect software historical data, perform intelligent analysis on the historical data, identify potential risk points, and then perform data preprocessing; The processing needs to generate diversified test scenarios, collect the historical data of the software, and analyze these historical data through large models to determine whether there are risk points. Risk points refer to factors that may cause software failures or performance problems, such as code defects, resource bottlenecks, etc. Then, the analyzed data is preprocessed. The data preprocessing process includes data format unification, quality improvement, standardization, data volume reduction, and annotation information processing. For details, please refer to the existing technology; Step 103: Select at least one test case template, and fill in the test case content in combination with the scenario generated by the large model and the historical data analysis results; When generating test cases, you need to select at least one test case template according to the software requirements, so that the generated test cases are more in line with the software requirements and do not need to be adjusted during subsequent testing. The test case content should be filled in with the scenarios generated by the large model and the historical data analysis results to ensure that the test coverage is comprehensive and efficient. In this way, the generated test cases can not only accurately simulate user behavior, but also effectively identify potential risks, thereby improving the comprehensiveness and accuracy of software testing.

[0024] Step 104: Verify and optimize the filled test cases, optimize the construction process according to the verification results, and update the historical data after the optimization is completed.

[0025] After filling in the test cases, in order to prevent defects in the test cases, verification and optimization are required to ensure their effectiveness and reliability, and the construction process is adjusted according to the verification results. The optimized data is updated to the historical database to form a closed-loop feedback mechanism to continuously improve the quality of test cases. Among them, the verification and optimization of the filled test cases can be carried out by combining automated testing tools or manual review to verify the coverage and accuracy of the test cases to ensure that there is no risk of omissions, and adjust the test strategy based on feedback to optimize the construction process, ultimately achieving continuous iteration and optimization of test cases.

[0026] Step 20: Modeling based on software requirements. The modeling process includes software requirement modeling, test intent statement recognition, test requirement content ontology construction, test condition entity attribute extraction, and generation of test case traversal and query functions. During the software testing process, modeling is also required based on software requirements. Software requirement modeling uses natural language processing technology, combined with artificial intelligence review, to model and reason about the knowledge graph of the requirements content; During the test process, since the test case contains text content, it usually contains various sentences, and these sentences need to be recognized during use, so as to identify the test intent and build an ontology model of the test requirement content. Specifically, the test intent sentence recognition uses the Bert model for semantic analysis, and the declaration of the requirement content is input into the model for keyword extraction. Combined with the pre-trained Bert model, the embedded representation of the sentence is obtained, and then the text classification algorithm TextCNN based on deep learning is used to classify the text content, identify the sentences with test intent and test requirements, and filter out irrelevant sentences; The construction of the test requirement content ontology includes: performing sentence pass and component analysis on the sentences with test intentions and test requirements in the requirement content to obtain the test requirement content components; obtaining the input combination of the test requirement statement test as the precondition entity, the test result as the postcondition entity, the intermediate precondition and postcondition entities are used to connect the precondition and postcondition, and the action entity is used to connect the adopted action steps, such as calling a function, pressing a button, toggling a switch, etc.; Among them, the test condition entity attribute extraction includes identifying the entity type and its attributes, such as parameter values ​​and operation steps. For the entity attribute extraction of pre- and post-condition entities, NER entity recognition and relationship extraction are used to identify the test variable type (integer, string, etc.) and logical operation (AND, OR, NOT, etc.) in the input conditions, identify the test unit and recursive structure, and obtain the test expert's experience and test requirements for the test type based on the type of test unit and structure, design the test scope and boundary conditions, and then perform equivalence class expansion and default value filling.

[0027] Step 30: Generate test scripts based on the big model, combine the demand model and test intent, automatically generate script code that conforms to the test logic, and verify the effectiveness of the script through simulation execution; A test script is a series of instructions that can be executed by automated testing tools. In order to improve the maintainability and reusability of test scripts, they must be constructed before they are executed. In traditional methods, test scripts usually need to be written manually, which is not only time-consuming but also prone to errors. Using large models to automatically generate scripts greatly improves efficiency and accuracy, ensuring comprehensive test coverage and reliable results. After generating the script code that conforms to the test logic, you need to simulate execution to verify the validity of the script, ensure that its performance in the actual test environment is consistent with expectations, and avoid potential errors and loopholes. Through simulated execution, defects in the script can be discovered and corrected in a timely manner, further improving the accuracy and reliability of the test and ensuring the smooth progress of the test process. At the same time, simulated execution can also verify the adaptability and stability of the script in different test scenarios, ensuring that it can still run efficiently in complex environments, thereby comprehensively improving test quality and reducing maintenance costs.

[0028] Step 40: Perform test knowledge graph reasoning, use the relationship between test entities and the reasoning pattern between relationship paths to generate semantic relationship calculations, and use knowledge graph path test traversal technology to generate coverage paths.

[0029] In the test knowledge graph, multi-step relational paths can reflect the semantic relations between test entities and realize semantic reasoning calculations. The relations between test entities and the reasoning patterns between relational paths are used to generate semantic relational calculations for representing test flows. During the reasoning process, it is necessary to use the knowledge graph path test traversal technology and adopt the key point path representation method. The key point path representation method includes the definition of entry key points and exit key points. The entry key point is the entry node of the control flow graph, and the exit key point is the exit node of the control flow graph; the branch key node is the description of the program branch in the control flow graph, and is a branch node with two direct successor nodes; the branch key point is decomposed from the loop node in the control flow graph.

[0030] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A test case generation method based on a large model, characterized in that: The method includes: Build test cases based on big models and knowledge graphs respectively, and generate system solutions based on the built test cases; Modeling is performed according to software requirements. The modeling process includes software requirement modeling, test intent statement recognition, test requirement content ontology construction, test condition entity attribute extraction, and test case traversal and query function generation; Generate test scripts based on large models, combine demand models and test intent, automatically generate script code that conforms to test logic, and verify script validity through simulation execution; Test knowledge graph reasoning, use the relationship between test entities and the reasoning pattern between relationship paths to generate semantic relationship calculations, and use knowledge graph path test traversal technology to generate coverage paths.

2. A test case generation method based on a large model according to claim 1, characterized in that: The construction of test cases based on the large model includes the following steps: According to the software functional requirements, use the big model to analyze user behavior and generate diversified test scenarios; collect software historical data, and perform intelligent analysis on the historical data to identify potential risk points, and then perform data preprocessing; select at least one test case template, and fill in the test case content in combination with the scenarios generated by the big model and the historical data analysis results; verify and optimize the filled test cases, and optimize the construction process based on the verification results. After the optimization is completed, update the historical data.

3. A test case generation method based on a large model according to claim 2, characterized in that: Verify and optimize the filled test cases using a combination of automated testing tools or manual review to verify the coverage and accuracy of the test cases.

4. The test case generation method based on a large model according to claim 1, characterized in that: Test intent sentence recognition uses the Bert model for semantic analysis. The requirement content and declarations are input into the model for keyword extraction. The pre-trained Bert model is combined to obtain the embedded representation of the sentence. Then, the deep learning-based text classification algorithm TextCNN is used to classify the text content, identify sentences with test intent and test requirements, and filter out irrelevant sentences.

5. The test case generation method based on a large model according to claim 2, characterized in that: The construction of the test requirement content ontology includes: performing sentence pass and component analysis on the sentences with test intentions and test requirements in the requirement content to obtain the components of the test requirement content; obtaining the input combination of the test requirement statement test as the precondition entity, the test result as the postcondition entity, the intermediate precondition and postcondition entities are used to connect the preconditions and postconditions, and the action entity is used to connect the adopted action steps.

6. The test case generation method based on a large model according to claim 2, characterized in that: Test condition entity attribute extraction includes identifying entity types and their attributes. For the entity attribute extraction of pre- and post-condition entities, NER entity recognition and relationship extraction are used to identify the test variable types and logical operation types in the input conditions, and to identify the test units and recursive structures.

7. The test case generation method based on a large model according to claim 2, characterized in that: According to the type of test unit and structure, obtain the test expert's experience and test requirements about the test type, design the scope and boundary conditions of the test, and then expand the equivalence class and fill in the default values.

8. The method for generating test cases based on a large model according to claim 1, characterized in that: During the reasoning process, the knowledge graph path test traversal technology is used and implemented using the key point path representation.

9. A test case generation method based on a large model according to claim 8, characterized in that: The key point path representation method includes defining entry key points and exit key points. The entry key point is the entry node of the control flow graph, and the exit key point is the exit node of the control flow graph. A branch node is a description of a program branch in a control flow graph and is a branch node with two direct successor nodes. Branch key points are decomposed from loop nodes in the control flow graph.

Citation Information

Cited By

  • Logic-driven test case generation method based on large language model

    CN120523743A

  • Intelligent test script generation and semantic maintenance method based on large language model

    CN120892346A