Industrial software test case generation method and device based on large language model
Through the test case generation method based on large language model, the problems of low efficiency and low quality of manual construction of test cases in the existing technology are solved, and automated test case generation is realized, testing efficiency and quality are improved, and testing needs of complex industrial software systems are met.
Patent Information
- Application Number
- CN202411990448.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2044-12-31
AI Technical Summary
The prior art relies on manual construction of test cases in software system testing, resulting in low efficiency and low quality, which cannot meet the complex and rapid development needs of modern software systems.
The industrial software test case generation method based on large language models is adopted. By obtaining prompt strategies and knowledge bases, the large language model is guided to generate test cases, and the system function description model and test case deployment information are used for optimization and code conversion to generate executable test case execution files.
It realizes automated test case generation, improves the generation efficiency and quality of test cases, and meets the testing needs of complex industrial software systems.
Smart Images

Figure CN119917410A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method and device for generating industrial software test cases based on a large language model. Background Art
[0002] With the increasing complexity of software systems and the shortening of development cycles, the traditional manual test case construction method can no longer meet the testing requirements of modern software systems. Automated testing, as an effective solution, can significantly improve testing efficiency and ensure software quality. However, almost all existing test cases are manually constructed, which takes a lot of time and results in low efficiency in test case generation. At the same time, the quality of manually constructed test cases is low and cannot meet the testing requirements of automated software systems. Summary of the invention
[0003] The main purpose of the embodiments of the present application is to propose a method and device for generating industrial software test cases based on a large language model, which can realize automated test case generation and improve the efficiency of test case generation.
[0004] On the one hand, an embodiment of the present application proposes a method for generating industrial software test cases based on a large language model, the method comprising the following steps:
[0005] Acquire a prompt strategy and a knowledge base, wherein the knowledge base is used to store background description information generated by industrial software test cases;
[0006] According to the prompt strategy, guiding the large language model to generate a test case according to the knowledge base, and outputting the corresponding first test case;
[0007] Obtain system functional description model;
[0008] Optimizing the first test case using the large language model according to the system function description model to generate a second test case;
[0009] The test case deployment information is obtained, and the second test case is subjected to code conversion processing by using the large language model according to the test case deployment information and the system function description model to generate a corresponding test case execution file.
[0010] In some embodiments, the acquisition of prompt strategies and knowledge bases specifically includes:
[0011] Acquire the background description information, wherein the background description information at least includes system function information, system application programming interface, system parameter description information, system interaction principle information and role definition information;
[0012] Building the knowledge base, and storing the background description information in the knowledge base;
[0013] Acquire test case generation prompt information, wherein the test case generation prompt information at least includes role information of the current generation environment, test case format constraint information, and a sample template of the test case;
[0014] Prompt information is generated according to the test case and the knowledge base, and the prompt strategy is generated.
[0015] In some embodiments, the obtaining of the system function description model specifically includes:
[0016] Obtaining system function description information; the system function description information includes description information of multiple system functions and description information of the interaction process of each system component when executing each of the system functions;
[0017] Mathematical modeling is performed based on the system function description information to establish a corresponding system function description model.
[0018] In some embodiments, optimizing the first test case using the large language model according to the system function description model to generate a second test case specifically includes:
[0019] Inputting the system function description model and the first test case into a large language model, and using the large language model to determine test sequence data matching the first test case from the system function description model;
[0020] Get the test path correction prompt word;
[0021] The test sequence data, the first test case and the test path correction prompt word are input into the large language model, the first test case is corrected using the large language model, the corrected first test case is output, and the corrected first test case is obtained as the second test case.
[0022] In some embodiments, the step of inputting the test sequence data, the first test case, and the test path correction prompt word into the large language model, correcting the first test case using the large language model, outputting the corrected first test case, and obtaining the corrected first test case as the second test case specifically includes:
[0023] Using the large language model to modify the prompt words according to the test path, performing a test process comparison on the first test case and the test sequence data, and determining a process comparison result;
[0024] When the process comparison result is that the test process is inconsistent, the first test case is corrected according to the test sequence data using the large language model, and the second test case is output.
[0025] In some embodiments, the acquiring of the test case deployment information, and using the large language model to perform code conversion processing on the second test case according to the test case deployment information and the system function description model to generate a corresponding test case execution file specifically includes:
[0026] Obtain the code generation template knowledge base and code generation prompt words corresponding to the test case;
[0027] The test sequence data, the code generation template knowledge base, the code generation prompt word and the second test case are input into the large language model, and the large language model is used to output the test case execution file corresponding to the second test case, wherein the test case execution file includes a test case name, a test case description, a test interface address, interface input parameters, the values of the interface input parameters, a test case code and a test case script execution code.
[0028] In some embodiments, the method further comprises:
[0029] Building the large language model;
[0030] The large language model is pre-trained using the knowledge base, wherein the knowledge base also includes a small sample learning data set.
[0031] On the other hand, an embodiment of the present application proposes an industrial software test case generation device based on a large language model, the device comprising:
[0032] The first module is used to obtain a prompt strategy and a knowledge base, wherein the knowledge base is used to store background description information generated by industrial software test cases;
[0033] A second module is used to guide the large language model to generate test cases according to the knowledge base according to the prompt strategy, and output the corresponding first test cases;
[0034] The third module is used to obtain the system function description model;
[0035] A fourth module is used to optimize the first test case by using the large language model according to the system function description model to generate a second test case;
[0036] The fifth module is used to obtain the test case deployment information, use the large language model to perform code conversion on the second test case according to the test case deployment information and the system function description model, and generate a corresponding test case execution file.
[0037] The embodiments of the present application include at least the following beneficial effects: the present application provides a method and device for generating industrial software test cases based on a large language model, which obtains a prompt strategy, a knowledge base, a system function description model, and test case deployment information, and guides the large language model to output a corresponding first test case according to the knowledge base according to the prompt strategy, optimizes the first test case according to the system function description model using the large language model, generates a second test case, and performs code conversion processing on the second test case according to the test case deployment information and the system function description model using the large language model to generate a corresponding test case execution file. The present application can realize automated test case generation through a large language model, improve the test case generation efficiency, improve the test case quality, and meet the testing requirements of industrial software systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0040] Figure 1 It is a flowchart of a method for generating industrial software test cases based on a large language model provided in an embodiment of the present application;
[0041] Figure 2 It is a structural schematic diagram of an industrial software test case generation device based on a large language model provided in an embodiment of the present application;
[0042] Figure 3 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0044] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0045] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0047] In the prior art, there are roughly three types of implementation plans for test case generation: the first is the traditional manual writing of test cases, which relies on fixed templates and the experience of test engineers. Although it can cover basic test requirements to a certain extent, it has the disadvantages of low efficiency, easy omissions and duplications; the second is to use a large language model to generate test cases and automatically generate test scenarios, which improves efficiency and consistency. However, due to the randomness of the model and insufficient understanding of complex industry standards, the generated test cases may have problems with accuracy and incomplete coverage; the third solution is to convert test cases into executable test tasks through test management tools and automated testing frameworks, automatically execute and generate reports, but in complex industrial software systems, due to complex business processes and frequent changes in requirements, the workload of writing and maintaining test scripts is huge, and the flexibility and coverage of test scripts often cannot meet the needs of high-frequency, large-scale testing tasks.
[0048] Based on this, the embodiment of the present application proposes a method and device for generating industrial software test cases based on a large language model, which can automatically generate test cases, avoid the inefficient manual writing process that relies on human experience, and combine the large language model and the Petri net model. By optimizing the test case generation strategy, the deviation of functional path generation is corrected. The Petri net model helps to more accurately describe the state and behavior of the industrial software system, so that the generated test cases not only meet the expected functional path, but also cover the complex interactions and business logic within the system, improving the accuracy and rigor of the test cases. The test case execution file is generated based on the large language model, and the generated test cases can be directly converted into executable test scripts, avoiding tedious manual script writing.
[0049] Reference Figure 1 , Figure 1 It is an optional flowchart of a method for generating industrial software test cases based on a large language model provided in an embodiment of the present application. The method may include but is not limited to steps S101 to S105:
[0050] Step S101, obtaining a prompt strategy and a knowledge base, where the knowledge base is used to store background description information generated by industrial software test cases;
[0051] Step S102, according to the prompt strategy, guiding the large language model to generate a test case according to the knowledge base, and outputting a corresponding first test case;
[0052] Step S103, obtaining a system function description model;
[0053] Step S104, optimizing the first test case according to the system function description model using the large language model to generate a second test case;
[0054] Step S105, acquiring the test case deployment information, using the large language model to perform code conversion processing on the second test case according to the test case deployment information and the system function description model, and generating a corresponding test case execution file.
[0055] In some embodiments, step S101 may include but is not limited to steps S201 to S204:
[0056] Step S201, obtaining background description information, the background description information at least including system function information, system application programming interface, system parameter description information, system interaction principle information and role definition information;
[0057] Step S202, constructing a knowledge base and storing the background description information in the knowledge base;
[0058] Step S203, obtaining test case generation prompt information, where the test case generation prompt information at least includes role information of the current generation environment, test case format constraint information, and a sample template of the test case;
[0059] Step S204, generating prompt information and a knowledge base according to the test case, and generating a prompt strategy.
[0060] In some embodiments, the knowledge base provides the large language model with detailed key information of the system, such as component functions, interaction principles, parameter requirements, and API interfaces, by introducing standardized filling of domain knowledge. Exemplarily, the knowledge base may include, but is not limited to, the following detailed key information of the system:
[0061] Role definition information: Defining roles can help large language models understand context and goals. For example, when a role is defined as "test engineer", the model will tend to generate content related to software testing and avoid generating answers that are not related to the topic. This clear role definition can ensure that the model's output is more focused and accurate;
[0062] Basic information of components: In order to guide the generation direction of the big language to be more in line with the test work content under the industrial software component system, some real data of the industrial software component system being used is obtained as background description information and filled into the knowledge base. The background description information may include but is not limited to the component function introduction, initialization setting requirements and corresponding API interface of the industrial software component system. And the filling unit is divided into components as the smallest unit, which can make the knowledge base more extensible;
[0063] System interaction principle information: Interaction principles include clarifying the usage prerequisites, interaction constraints, and execution flow of system functions between components. The usage prerequisites between components refer to the basic conditions and states that each component needs to meet before interacting. These prerequisites ensure that components interact in the correct environment and state, thereby avoiding errors and exceptions caused by unsatisfied conditions. Interaction constraints between components refer to the rules and restrictions that each component must follow during the interaction process, aiming to ensure that the interaction process between components is smooth and error-free. The execution flow of industrial software component system functions refers to a series of action definitions that clarify the roles and tasks of each component in the execution of specific functions. The entire execution process needs to be carried out strictly in accordance with predefined steps to ensure the accuracy and reliability of system functions;
[0064] System parameter description information: Some components involving parameter requirements are marked in natural language, such as coordinate information, image data, control commands, etc. They include parameter type, range, default value and constraints. This information helps the large language model pay attention to the requirements of these parameters during the production process and ensure that the test covers various boundary conditions and abnormal situations.
[0065] System Application Programming Interface: This describes the component's API interface in detail, including the method name, parameter requirements, response format, and sample code for each API interface. The API interface document provides a corresponding mapping for the large language model to match the component's API interface, facilitating code generation for functional testing;
[0066] Generate content format constraint information: By defining clear JSON format constraints, the data structure, field type, required items, and optional items of the generated test cases can be standardized, so that the data can be accurately identified and used during transmission and processing, and it helps to locate and solve problems more quickly during development, debugging, and maintenance, ultimately improving the overall performance and stability of the system;
[0067] Small sample learning dataset: By providing multiple pairs of test case samples of expected output to train large language models to solve tasks, this can effectively increase the efficiency of large language models in outputting expected content.
[0068] In some embodiments, taking the construction of a knowledge base of a componentized industrial software system as an example, the knowledge base is used to store detailed description information of the componentized industrial software system (such as the above-mentioned background description information), including basic information of the industrial software system components, interaction principles, parameter requirements, API interfaces corresponding to the components, and prompt templates, etc. This information provides a clear knowledge basis for the large language model through standardized descriptions, so that the large language model can more accurately generate test cases that meet actual needs. The knowledge base simplifies the knowledge input process by expressing the technical details of complex componentized industrial software systems in natural language form, and realizes efficient automation of test case generation. It not only effectively solves the problem of insufficient coverage of complex scenarios by traditional methods, but also improves the scalability and accuracy of test cases in various practical application scenarios.
[0069] In some embodiments, based on the prompt information and knowledge base generated according to the test case, a prompt strategy is generated, and the prompt strategy is used to guide the large language model to generate test cases, so that the large language model can accurately understand the user input, and generate comprehensive coverage and test content that conforms to the API parameter format in combination with the knowledge base information. Through the prompt strategy, the large language model can generate test cases based on the interaction logic and data dependencies of different APIs. The generated test cases not only meet the system functional requirements, but also have sufficient coverage and accuracy, which improves the effectiveness of test case generation and provides technical support for the automated testing of complex industrial software systems.
[0070] This prompt strategy uses a large language model and prompt engineering to achieve automatic generation of test cases. By effectively using the large language model to generate process modeling prompt strategies, the large language model is guided to accurately understand the provided knowledge background description and target generation process model. This prompt strategy can guide the large language model to quickly locate and extract the knowledge base information required to perform the task when performing the test case generation task.
[0071] Exemplarily, the prompt strategy may be: input the role definition of the current generation environment → input the system knowledge background → input the constraints of the generated content format → input a small number of sample templates of expected output → output the generated result.
[0072] In some embodiments, step S103 may include but is not limited to steps S301 to S302:
[0073] Step S301, obtaining system function description information; the system function description information includes description information of multiple system functions and description information of the interaction process of each system component when executing each system function;
[0074] Step S302: Perform mathematical modeling based on the system function description information to establish a corresponding system function description model.
[0075] In some embodiments, the above system function description model is a Petri net model. The Petri net model is a logical model used to describe and analyze asynchronous concurrent systems and can express concurrent events and state changes in the system.
[0076] According to the component workflow involved in each system function (such as the system function description information mentioned above), Petri net modeling is performed to obtain the corresponding Petri net model. The Petri net model describes the interaction process between components in the form of a mathematical model and stores it in JSON format. Combining the Petri net model to generate test cases can effectively improve the coverage of test cases, make the generated test paths meet the requirements of engineering testing, reduce the risk of missing key boundary conditions or abnormal scenarios, and thus ensure the reliability and accuracy of the test results. The test path can be used to generate multiple test cases.
[0077] Optionally, the Petri net model is defined in JSON format. The JSON Schema corresponding to the JSON format specifies the structure of the Petri net model, including three main parts: nodes, changes, and connections. Nodes represent all node sets in the Petri net, which can be system states, resources, or other important elements. Changes represent all transition sets, i.e., operations or events in which the state of the system changes. Connections is an array of objects, each of which defines a connection relationship, including source and target. These connections describe the transfer relationship from a certain node to a certain transition, or from a transition to the next node. In this structured way, the composition of the Petri net model and the interaction relationship between components can be clearly expressed, thereby ensuring the correctness and consistency of the Petri net model. In practical applications, this JSON Schema structure facilitates the verification and parsing of the Petri net model, so that the generated test cases can achieve comprehensive coverage of system functions, while improving the accuracy and efficiency of test path generation.
[0078] In some embodiments, step S104 may include but is not limited to steps S401 to S403:
[0079] Step S401, inputting the system function description model and the first test case into the large language model, and using the large language model to determine the test sequence data matching the first test case from the system function description model;
[0080] Step S402, obtaining a test path correction prompt word;
[0081] Step S403: input the test sequence data, the first test case and the test path correction prompt word into the large language model, use the large language model to correct the first test case, output the corrected first test case, and obtain the corrected first test case as the second test case.
[0082] In some embodiments, the system function description model not only records the function execution process of each component in the system, but also systematically defines the interaction relationship between each component. The system function description model, the test path correction prompt words and the first test case are input into the large language model, and the first test case is corrected by the large language model, and the above-mentioned second test case is output, so that the large language model can adjust the generated test cases according to the actual application scenarios, cover more comprehensive test paths, and improve the accuracy and effectiveness of the testing work.
[0083] Optionally, the large language model outputs test case JSON data that meets the input requirements. In order to improve the visualization effect, Python's pandas library will be used to convert the test case JSON data into an Excel table. This data conversion method can not only present the test cases in a more intuitive way, but also facilitate test engineers to view, edit and analyze test cases. Through this Excel table, users can more easily manage and optimize the test process, further improve the quality and coverage of test cases, and improve the comprehensiveness and accuracy of test work.
[0084] In some embodiments, step S403 may include but is not limited to steps S501 to S502:
[0085] Step S501, using a large language model to modify prompt words according to the test path, performing a test process comparison on the first test case and the test sequence data, and determining a process comparison result;
[0086] Step S502: When the process comparison result is that the test process is inconsistent, the first test case is corrected according to the test sequence data using the large language model, and a second test case is output.
[0087] In some embodiments, step S105 may include but is not limited to steps S601 to S602:
[0088] Step S601, obtaining a code generation template knowledge base and code generation prompt words corresponding to the test case;
[0089] Step S602, input the test sequence data, the code generation template knowledge base, the code generation prompt words and the second test case into the large language model, and use the large language model to output the test case execution file corresponding to the second test case. The test case execution file includes the test case name, test case description, test interface address, interface input parameters, interface input parameter values, test case code and test case script execution code.
[0090] In some embodiments, specifically, test cases are quickly converted into executable script codes through a large language model, reducing the tediousness of manual writing and improving the efficiency and accuracy of testing.
[0091] Optionally, the above-mentioned large language model encapsulates the component's service request method and service result verification method for the generation of test case workflow script code. This encapsulation method abstracts the underlying API call and result verification process, reduces the error probability when the large language model generates business code, enhances the accuracy and maintainability of code generation during test automation, improves test efficiency and realizes rapid code deployment. The writing of test code only needs to focus on key information such as the component's API interface and incoming parameters, greatly simplifying the writing and maintenance of test cases.
[0092] According to the generated second test case and the test sequence data in its corresponding Petri net model, it can be confirmed that it can match the designed code interface processing. The nodes in the test sequence data can be regarded as the triggers of the API request, and the transitions represent the expected results of the previous node action, that is, the verification of the service results. During the code generation process, based on the capabilities of the large language model, complex business logic can be automatically generated, including the verification processing of the call and return status of component services.
[0093] In some embodiments, a code generation template knowledge base and code generation prompt words are introduced to implement behavioral programming. Behavioral programming (BP) emphasizes the response of the system in different states. By separating and combining these states and behaviors, the behavior and state transition of the system are more clearly defined. This method can not only improve the readability of the code, but also make the operation logic more intuitive and clear, which is convenient for the generation of test cases, code maintenance and subsequent optimization. Through this structured representation method, system code generation can be more efficient, reduce maintenance costs and improve the overall controllability of the test workflow.
[0094] In some embodiments, the test case generation method may include but is not limited to steps S701 to S702:
[0095] Step S701, constructing a large language model;
[0096] Step S702, pre-training the large language model using a knowledge base, wherein the knowledge base also includes a small sample learning data set.
[0097] In some embodiments, the small sample learning data set includes multiple pairs of test case samples of expected outputs, and the large language model is pre-trained through the small sample learning data set, effectively increasing the efficiency of the large language model in outputting expected content.
[0098] In some embodiments, taking a componentized industrial software system as an example, the above-mentioned industrial software test case generation method based on a large language model is applied to generate test cases for the componentized industrial software system. Specifically, the automatic dispensing function scenario in the componentized industrial software system is selected. This scenario describes the whole process of the robot arm cooperating with the visual camera to control the glue gun to complete the dispensing action by identifying and transferring the target position. After the dispensing action is completed, the robot arm is reset, which means the execution of the entire function is completed. The test case generation process corresponding to this scenario is as follows:
[0099] The first step is to obtain the operation steps of the automatic dispensing function, as follows:
[0100] 1) The system uses the robot base moving assembly to reset the robot arm, initialize the glue gun assembly and the visual camera assembly;
[0101] 2) The system calls the visual camera component and transmits the dispensing position coordinates;
[0102] 3) The system calls the robot arm base moving component to move to the dispensing position according to the position sequence recognized by the visual camera;
[0103] 4) The system calls the robot arm to move the assembly to the dispensing distance;
[0104] 5) The system calls the dispensing component to complete the dispensing;
[0105] 6) The system calls the robot arm movement component to reset;
[0106] 7) Repeat steps 3) to 6) until all the required dispensing coordinates have completed the dispensing action;
[0107] 8) The system calls the robot base moving component to reset.
[0108] In the second step, combining the operation steps of the automatic dispensing function and the test background of the componentized industrial software system, a knowledge base is generated to edit the test guidance knowledge, and it is named as the `test_case_generation_data.md` file. Then, by calling the multi-round dialogue API interface of the large language model, the user's expected generated content, generation requirements, and the `test_case_generation_data.md` file are packaged and transmitted to the large language model. After receiving the transmitted data, the large language model generates prompt words through the test case to guide the large language model to analyze the packaged file, generate and return the JSON format data of the first test case, and the JSON format data of the first test case is stored in the `test_outcome.md` file;
[0109] The third step is to use the test path correction prompt word, and the large language model compares the test case generation data in the `test_outcome.md` file with the real case Petri net model `llm_petri.md` file of the industrial software component system for the test sequence. The large language model finds the corresponding Petri net model test sequence data in the `llm_petri.md` file according to the test case name, and compares the test process. After the process comparison is completed, assuming that the test process conforms to the corresponding test process in the Petri net model, that is, the test process is consistent, the large language model will return the final JSON data and a description of the matching result. If the test process is inconsistent, the first test case is corrected according to the Petri net model test sequence data to generate a second test case, and the JSON format data of the second test case and the description of the correction content are returned. The JSON format data of the second test case is stored in the `test_final_outcome.md file;
[0110] Step 4: Use Python's pandas library to convert the JSON data of the `test_final_outcome.md` file and generate an Excel table;
[0111] In the fifth step, the `test_final_outcome.md` file and the `llm_petri.md` file are used as input, and the large language model is used to filter out the Petri net model data corresponding to the test case function (i.e., the above-mentioned Petri net model test sequence data), and integrate the output into the `petri_code_data.md` file. Subsequently, the `petri_code_data.md` file and the code generation template knowledge base `llm_code_gen.md` file are used as input together, and the code generation prompt words are used to instruct the large language model to generate the corresponding test case execution file.
[0112] Reference Figure 2 , Figure 2 It is an optional structural diagram of an industrial software test case generation device based on a large language model provided in an embodiment of the present application. The device is used to implement the above-mentioned industrial software test case generation method. The device may include:
[0113] The first module is used to obtain prompt strategies and knowledge base, and the knowledge base is used to store background description information generated by industrial software test cases;
[0114] The second module is used to guide the large language model to generate test cases according to the knowledge base according to the prompt strategy, and output the corresponding first test cases;
[0115] The third module is used to obtain the system function description model;
[0116] The fourth module is used to optimize the first test case according to the system function description model by using the large language model to generate a second test case;
[0117] The fifth module is used to obtain the test case deployment information, use the large language model to perform code conversion on the second test case according to the test case deployment information and the system function description model, and generate a corresponding test case execution file.
[0118] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0119] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above industrial software test case generation method when executing the computer program. The electronic device can be any smart terminal including a tablet computer.
[0120] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0121] See also Figure 3 , Figure 3 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0122] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0123] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the industrial software test case generation method of the embodiment of this application;
[0124] Input / output interface 903, used to implement information input and output;
[0125] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0126] A bus 905 that transmits information between the various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0127] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0128] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned industrial software test case generation method is implemented.
[0129] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0130] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0131] The embodiments of the present application provide a method and device for generating industrial software test cases based on a large language model, which can realize automated test case generation through a large language model, improve the efficiency of test case generation, enhance the quality of test cases, and meet the needs of automated software system testing.
[0132] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0133] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0134] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0135] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0136] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0137] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0138] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for generating industrial software test cases based on a large language model, characterized in that: The method comprises the following steps: Acquire a prompt strategy and a knowledge base, wherein the knowledge base is used to store background description information generated by industrial software test cases; According to the prompt strategy, guiding the large language model to generate a test case according to the knowledge base, and outputting the corresponding first test case; Obtain system functional description model; Optimizing the first test case using the large language model according to the system function description model to generate a second test case; The test case deployment information is obtained, and the second test case is subjected to code conversion processing by using the large language model according to the test case deployment information and the system function description model to generate a corresponding test case execution file.
2. The method for generating industrial software test cases according to claim 1, characterized in that: The acquisition prompt strategy and knowledge base specifically include: Acquire the background description information, wherein the background description information at least includes system function information, system application programming interface, system parameter description information, system interaction principle information and role definition information; Building the knowledge base, and storing the background description information in the knowledge base; Acquire test case generation prompt information, wherein the test case generation prompt information at least includes role information of the current generation environment, test case format constraint information, and a sample template of the test case; Prompt information is generated according to the test case and the knowledge base, and the prompt strategy is generated.
3. The method for generating industrial software test cases according to claim 1, characterized in that: The obtaining of the system function description model specifically includes: Obtaining system function description information; the system function description information includes description information of multiple system functions and description information of the interaction process of each system component when executing each of the system functions; Mathematical modeling is performed based on the system function description information to establish a corresponding system function description model.
4. The method for generating industrial software test cases according to claim 1, characterized in that: The optimizing the first test case according to the system function description model using the large language model to generate a second test case specifically includes: Inputting the system function description model and the first test case into a large language model, and using the large language model to determine test sequence data matching the first test case from the system function description model; Get the test path correction prompt word; The test sequence data, the first test case and the test path correction prompt word are input into the large language model, the first test case is corrected using the large language model, the corrected first test case is output, and the corrected first test case is obtained as the second test case.
5. The method for generating industrial software test cases according to claim 4, characterized in that: The step of inputting the test sequence data, the first test case, and the test path correction prompt word into the large language model, correcting the first test case using the large language model, outputting the corrected first test case, and obtaining the corrected first test case as the second test case specifically includes: Using the large language model to modify the prompt words according to the test path, performing a test process comparison on the first test case and the test sequence data, and determining a process comparison result; When the process comparison result is that the test process is inconsistent, the first test case is corrected according to the test sequence data using the large language model, and the second test case is output.
6. The method for generating industrial software test cases according to claim 4, characterized in that: The acquiring of the test case deployment information, and performing code conversion processing on the second test case using the large language model according to the test case deployment information and the system function description model to generate a corresponding test case execution file specifically includes: Obtain the code generation template knowledge base and code generation prompt words corresponding to the test case; The test sequence data, the code generation template knowledge base, the code generation prompt word and the second test case are input into the large language model, and the large language model is used to output the test case execution file corresponding to the second test case, wherein the test case execution file includes a test case name, a test case description, a test interface address, interface input parameters, the values of the interface input parameters, a test case code and a test case script execution code.
7. The method for generating industrial software test cases according to claim 1, characterized in that: The method further comprises: Building the large language model; The large language model is pre-trained using the knowledge base, wherein the knowledge base also includes a small sample learning data set.
8. An industrial software test case generation device based on a large language model, characterized in that: The device comprises: The first module is used to obtain a prompt strategy and a knowledge base, wherein the knowledge base is used to store background description information generated by industrial software test cases; A second module is used to guide the large language model to generate test cases according to the knowledge base according to the prompt strategy, and output the corresponding first test cases; The third module is used to obtain the system function description model; A fourth module is used to optimize the first test case by using the large language model according to the system function description model to generate a second test case; The fifth module is used to obtain the test case deployment information, use the large language model to perform code conversion on the second test case according to the test case deployment information and the system function description model, and generate a corresponding test case execution file.
Citation Information
Patent Citations
Test case generation method and device as well as test method and device
CN113641591A
Test case generation method and device, electronic equipment and storage medium
CN117573507A
Test case generation method and device, storage medium and computer equipment
CN119046132A
Automatic testing method and device based on large model, and electronic equipment
CN119127686A
Optimizing test case execution
US11182279B1
Cited By
Test script generation method and device, storage medium and program product
CN120723657A
Model-driven algorithm test method and system, computer and storage medium
CN121051028A
A model-driven algorithm testing method, system, computer and storage medium
CN121051028B