Method and device for automatically generating test case documents in preset format in batches
By using excel table templates and large language models to generate standardized test case documents, the problems of low efficiency and poor usability of test case generation in the existing technology are solved, and standard test cases are automatically generated in batches are realized, and the efficiency of software functional testing is improved.
Patent Information
- Application Number
- CN202411187645.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-27
AI Technical Summary
The prior art is difficult to automatically generate standardized preset format test case documents in batches, and complex logic and constraint information will be lost when identifying functions from user interface screenshots. The generated test cases are not available, and the user interface screenshots of each function point are prepared. Complex and time-consuming.
By using excel table templates to organize the list of function points and basic information, create Q&A prompt words for large language models, use large language models to generate original test cases, and format them through text processing technology to generate standard test case objects, and follow predefined formats. Generate test case documents in word or markdown format.
It improves the efficiency of test case writing for software function testers, and realizes automated batch generation of test cases. The generated test cases are standardized and highly available, reducing the complexity of manual sorting and screenshot preparation.
Smart Images

Figure CN119201688A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of test case generation, in particular to a method and a device for automatically batch generating test case documents in a preset format. Background Art
[0002] The following technologies are used to generate functional test cases based on large language models:
[0003] (1) Intelligent recommendation based on the existing test case library. The core is to use a large model to analyze the test requirements and determine a retrieval method to more accurately select the test case set that meets the current test requirements from the existing and well-maintained test case library, without actually generating test cases.
[0004] (2) Generate test cases for only a single function point each time. Users can collect test requirements and constraints for a single function point by selecting or directly inputting them in the system. The collected test requirements and constraints can be further input into the big model, which will then optimize and supplement the test requirements and constraints. Finally, the test requirements and constraints and other information can be input into the big model to generate test cases. This is only applicable to scenarios where test cases are generated for a single function point, and there is no further standardized processing of test cases. The format of the test cases is uncertain.
[0005] (3) Based on the big model, elements and functions are identified from the user interface screenshots of the system under test, and converted into some inputs, and test cases are generated by the big model. Identifying functions only from user interface screenshots has certain limitations, and some more complex logic and constraint information will be lost, and the generated test cases are not highly usable; moreover, preparing user interface screenshots for each functional point is also a complex and time-consuming project. Summary of the invention
[0006] In view of the needs and shortcomings of current technological development, the present invention provides a method and device for automatically batch generating test case documents in a preset format, aiming to help software functional testers improve the efficiency of test case writing.
[0007] In a first aspect, the present invention provides a method for automatically batch-generating test case documents in a preset format. The technical solution adopted to solve the above technical problem is as follows:
[0008] A method for automatically batch-generating test case documents in a preset format comprises the following steps:
[0009] S1. Testers use the Excel spreadsheet template to organize a list of function points in a certain range or the entire software system under test, mark the chapter number of the function point in the requirements specification, and organize a description for each function point;
[0010] S2. Create test tasks and maintain the four basic information of the tested software system: name, version, tester and test time;
[0011] S3, traverse the function point list line by line, parse and convert it into function point objects, and store them in a relational database;
[0012] S4. Create a large language model of question and answer prompts for each function point;
[0013] S5. Use question-answer prompts to communicate with the large language model. The large language model outputs the original test case, formats the original test case using text processing technology, generates a standard test case object, stores it in a relational database, and associates it with each function point.
[0014] S6. Based on the scope of the function point list, the standard test case objects stored in the relational database are converted into a test case document in a word format according to a predefined test case document format.
[0015] Optionally, when executing step S4 to create question and answer prompt words of the large language model for each function point, the created question and answer prompt words include background and instruction information, description information of the function point, rules for generating normal use cases and abnormal use cases, elements that the test case needs to include, and output format and examples of the test case.
[0016] Optionally, the output format of the test case is designed to be markdown format;
[0017] Execute step S5. After the large language model outputs the original test case, the original test case is converted into markdown format using regular expression character replacement technology. The test case in markdown format is then parsed to generate a standard test case object containing four elements: test case name, test objective, steps, and expected results, and the object is stored in a relational database.
[0018] Further optionally, step S6 is performed, and the predefined test case document includes the use case identifier, the chapter number in the requirement specification, the designer, the functional description, the quality characteristics, the termination condition, the operation steps and the expected results.
[0019] Preferably, the large language model adopts one of Wenxinyiyan, ChatGPT, Pangu, Tongyi, and Hunyuan.
[0020] In a second aspect, the present invention provides a device for automatically batch-generating test case documents in a preset format. The technical solution adopted to solve the above technical problem is as follows:
[0021] A device for automatically batch-generating test case documents in a preset format, comprising:
[0022] The Excel template module is used to assist testers to use Excel spreadsheet templates to complete the following operations: organize a list of function points within a certain range or the entire software system under test, mark the chapter number of the function point in the requirements specification, and organize a description for each function point;
[0023] The task creation module is used to create test tasks and maintain the four basic information of the tested software system: name, version, tester and test time;
[0024] The information collection module is used to traverse the function point list line by line, parse and convert it into function point objects, and store it in the relational database;
[0025] The prompt word creation module is used to create question and answer prompt words for each function point in the large language model;
[0026] A large language model is used to output original test cases based on the question and answer prompts;
[0027] Intelligent question-answering module, which uses text processing technology to format the original test cases, generate standard test case objects, store them in a relational database, and associate them with each function point;
[0028] The document generation module is used to generate a test case document in word format according to the predefined test case document format from the standard test case objects stored in the relational database based on the scope of the function point list.
[0029] Optionally, the question and answer prompt words created by the prompt word creation module include background and instruction information, description information of functional points, rules for generating normal use cases and abnormal use cases, elements that test cases need to include, and output formats and examples of test cases.
[0030] Further optionally, the output format of the test cases involved is designed to be in markdown format;
[0031] After the large language model outputs the original test case, the intelligent question-and-answer module involved uses regular expression character replacement technology to convert the original test case into markdown format, and then parses the test case in markdown format to generate a standard test case object containing four elements: test case name, test objective, steps, and expected results, and stores it in a relational database.
[0032] Optionally, the predefined test case document contains the use case identifier, section number in the requirements specification, designer, functional description, quality characteristics, termination conditions, operation steps and expected results.
[0033] Preferably, the large language model involved adopts one of Wenxinyiyan, ChatGPT, Pangu, Tongyi, and Hunyuan.
[0034] Compared with the prior art, the method and device of the present invention for automatically batch generating test case documents in a preset format have the following beneficial effects:
[0035] 1. The present invention can help software function testers improve the efficiency of test case writing by manually arranging the function point list and basic information, automatically generating standard test case objects, and generating test case documents in word format that conform to preset format specifications;
[0036] 2. The present invention is aimed at software functional testers and can provide a process operation for automatically and batch-generating functional test cases for a certain demarcated functional point range or the entire system under test. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Attached Figure 1 is a flow chart of a method according to Embodiment 1 of the present invention;
[0038] Attached Figure 2 This is a module connection block diagram of the second embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.
[0040] Embodiment 1:
[0041] Combined with Figure 1 This embodiment proposes a method for automatically batch generating test case documents in a preset format, which includes the following steps:
[0042] S1. Testers use Excel spreadsheet templates to organize a list of function points for a certain range of function points or the entire software system under test, mark the chapter numbers of the function points in the requirements specification, and organize a description for each function point.
[0043] S2. Create test tasks and maintain four basic information of the software system under test: name, version, tester and test time.
[0044] S3. Traverse the function point list line by line, parse and convert it into function point objects, and store them in a relational database.
[0045] S4. Create a large language model of question and answer prompts for each function point. The question and answer prompts include background and instruction information, description information of the function point, rules for generating normal and abnormal test cases, elements that test cases need to include, output format of test cases and examples, among which:
[0046] The elements that a test case needs to contain include the test case name, test objectives, steps, and expected results;
[0047] The output format of the test case is designed to be markdown format.
[0048] For example, based on the text "You are a software test engineer. The following is the function point description information: A smart factory system-smart warehousing-main service (PC side)-user management-operation log, query the operation log according to the system module, operator, type, status, and operation time. The operation log can be cleared and exported. The operation log includes fields such as log number, system module, operation type, request method, operator, host, operation location, operation status, and operation date. Please design test cases, including normal cases and abnormal cases. The use case elements include the use case name, test objectives, steps, and expected results. The output format is designed to be markdown format", the question and answer prompts created are as follows:
[0049] (a) Background and instructions: You are a software test engineer. Please design test cases.
[0050] (b) Description of function points: A smart factory system - smart warehousing - main service (PC side) - user management - operation log, query the operation log according to the system module, operator, type, status, and operation time. The operation log can be cleared and exported. The operation log includes fields such as log number, system module, operation type, request method, operator, host, operation location, operation status, and operation date.
[0051] (c) Rules for generating normal use cases and abnormal use cases: including normal use cases and abnormal use cases.
[0052] (d) Elements that a test case needs to include: test case name, test objectives, steps, and expected results.
[0053] (e) Test case output format and examples: The markdown format is agreed upon.
[0054] S5. Use question and answer prompts to communicate with the large language model. The large language model outputs the original test cases, formats the original test cases using text processing technology, generates standard test case objects, stores them in a relational database, and associates them with each functional point.
[0055] The large language model adopts one of Wenxinyiyan, ChatGPT, Pangu, Tongyi, and Hunyuan. The large language model can generate coherent text according to the input prompt words. The large language model described in this embodiment is obtained by training a large amount of text data. In actual use, a trained large language model can be accessed, such as by calling a third-party service through an API or using an open source model.
[0056] Specifically, the regular expression character replacement technology is used to convert the original test case into the markdown format, and then the test case in the markdown format is parsed to generate a standard test case object containing four elements: test case name, test objective, steps, and expected results, and store it in a relational database.
[0057] S6. Based on the scope of the function point list, the standard test case objects stored in the relational database are converted into a test case document in a word format according to a predefined test case document format.
[0058] The predefined test case document contains the use case identifier, section number in the requirements specification, designer, functional description, quality characteristics, termination conditions, operation steps and expected results.
[0059] Convert the test case object into a word document. You may need to use a specific library or tool to process it, such as the python-docx library in Python.
[0060] Embodiment 2:
[0061] Combined with Figure 2 This embodiment proposes a device for automatically batch-generating test case documents in a preset format, which includes:
[0062] The Excel template module is used to assist testers to use Excel spreadsheet templates to complete the following operations: organize a list of function points within a certain range or the entire software system under test, mark the chapter number of the function point in the requirements specification, and organize a description for each function point;
[0063] The task creation module is used to create test tasks and maintain the four basic information of the tested software system: name, version, tester and test time;
[0064] The information collection module is used to traverse the function point list line by line, parse and convert it into function point objects, and store it in the relational database;
[0065] The prompt word creation module is used to create a question and answer prompt word of the large language model for each function point. The question and answer prompt word includes background and instruction information, description information of the function point, rules for generating normal use cases and abnormal use cases, elements that need to be included in the test case, and the output format and examples of the test case. Among them, the elements that need to be included in the test case include the test case name, test objectives, steps and expected results. The output format of the test case is designed to be markdown format;
[0066] A large language model is used to output original test cases based on the question and answer prompts;
[0067] Intelligent question-answering module, which uses text processing technology to format the original test cases, generate standard test case objects, store them in a relational database, and associate them with each function point;
[0068] The document generation module is used to generate a test case document in word format according to the predefined test case document format from the standard test case objects stored in the relational database based on the scope of the function point list; wherein the predefined test case document includes the use case identifier, the chapter number in the requirement specification, the designer, the functional description, the quality characteristics, the termination condition, the operation steps and the expected results.
[0069] In this embodiment, after the large language model outputs the original test case, the intelligent question and answer module involved uses regular expression character replacement technology to convert the original test case into markdown format, and then parses the test case in markdown format to generate a standard test case object containing four elements: test case name, test objectives, steps, and expected results, and stores it in a relational database.
[0070] In this embodiment, the large language model adopts one of Wenxinyiyan, ChatGPT, Pangu, Tongyi, and Hunyuan. The large language model can generate coherent text according to the input prompt words. The large language model described in this embodiment is obtained by training a large amount of text data. In actual use, a trained large language model can be accessed, such as by calling a third-party service through an API or using an open source model.
[0071] In summary, the method and device of the present invention for automatically batch generating test case documents in a preset format can help software functional testers improve the efficiency of test case writing by manually organizing a list of function points and basic information, automatically generating standard test case objects, and generating test case documents in a word format that conforms to preset format specifications.
[0072] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.
Claims
1. A method for automatically batch generating test case documents in a preset format, characterized in that: The steps include: S1. Testers use the Excel spreadsheet template to organize a list of function points in a certain range or the entire software system under test, mark the chapter number of the function point in the requirements specification, and organize a description for each function point; S2. Create test tasks and maintain the four basic information of the tested software system: name, version, tester and test time; S3, traverse the function point list line by line, parse and convert it into function point objects, and store them in a relational database; S4. Create a large language model of question and answer prompts for each function point; S5. Use question-answer prompts to communicate with the large language model. The large language model outputs the original test case, formats the original test case using text processing technology, generates a standard test case object, stores it in a relational database, and associates it with each function point. S6. Based on the scope of the function point list, the standard test case objects stored in the relational database are converted into a test case document in a word format according to a predefined test case document format.
2. A method for automatically batch generating test case documents in a preset format according to claim 1, characterized in that: When executing step S4 to create a question and answer prompt word of the large language model for each function point, the created question and answer prompt word includes background and instruction information, description information of the function point, rules for generating normal use cases and abnormal use cases, elements that the test case needs to include, and output format and examples of the test case.
3. A method for automatically batch generating test case documents in a preset format according to claim 2, characterized in that: The output format of the test case is designed to be markdown format; Execute step S5. After the large language model outputs the original test case, the original test case is converted into markdown format using regular expression character replacement technology. The test case in markdown format is then parsed to generate a standard test case object containing four elements: test case name, test objective, steps, and expected results, and the object is stored in a relational database.
4. The method for automatically batch generating test case documents in a preset format according to claim 2, characterized in that: Execute step S6, the predefined test case document includes the use case identifier, the chapter number in the requirement specification, the designer, the functional description, the quality characteristics, the termination condition, the operation steps and the expected results.
5. The method for automatically batch generating test case documents in a preset format according to claim 1, characterized in that: The large language model adopts one of Wenxinyiyan, ChatGPT, Pangu, Tongyi, and Hunyuan.
6. A device for automatically generating batches of test case documents in a preset format, characterized in that: It includes: The Excel template module is used to assist testers to use Excel spreadsheet templates to complete the following operations: organize a list of function points within a certain range or the entire software system under test, mark the chapter number of the function point in the requirements specification, and organize a description for each function point; The task creation module is used to create test tasks and maintain the four basic information of the tested software system: name, version, tester and test time; The information collection module is used to traverse the function point list line by line, parse and convert it into function point objects, and store it in the relational database; The prompt word creation module is used to create question and answer prompt words for each function point in the large language model; A large language model is used to output original test cases based on the question and answer prompts; Intelligent question-answering module, which uses text processing technology to format the original test cases, generate standard test case objects, store them in a relational database, and associate them with each function point; The document generation module is used to generate a test case document in word format according to the predefined test case document format from the standard test case objects stored in the relational database based on the scope of the function point list.
7. The device for automatically batch-generating test case documents in a preset format according to claim 6, characterized in that: The question and answer prompt words created by the prompt word creation module include background and instruction information, description information of functional points, rules for generating normal use cases and abnormal use cases, elements that need to be included in the test cases, and output formats and examples of the test cases.
8. The device for automatically batch-generating test case documents in a preset format according to claim 7, characterized in that: The output format of the test case is designed to be markdown format; After the large language model outputs the original test case, the intelligent question and answer module uses regular expression character replacement technology to convert the original test case into markdown format, and then parses the test case in markdown format to generate a standard test case object containing four elements: test case name, test objective, steps, and expected results, and stores it in a relational database.
9. The device for automatically batch-generating test case documents in a preset format according to claim 7, characterized in that: The predefined test case document contains the use case identifier, section number in the requirements specification, designer, functional description, quality characteristics, termination conditions, operation steps and expected results.
10. The device for automatically batch-generating test case documents in a preset format according to claim 6, characterized in that: The large language model adopts one of Wenxinyiyan, ChatGPT, Pangu, Tongyi, and Hunyuan.
Citation Information
Cited By
Database test case generation and optimization method, system and equipment and storage medium
CN120162249A