Test case generation method and device, electronic equipment and storage medium

By normalizing and generating templates for software requirements using a large language model, the problem of low accuracy in test case generation is solved, achieving highly accurate and automated test case generation and ensuring comprehensive verification of software functions.

CN122261981APending Publication Date: 2026-06-23BEIJING CO WHEELS TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING CO WHEELS TECH CO LTD
Filing Date
2024-12-23
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing technologies, the accuracy of generating software qualification test cases is low, resulting in insufficient verification of software functions and difficulty in achieving the requirement of full coverage of test code.

Method used

The initial software requirement information is normalized using a large language model to generate target software requirement information. Test cases are then generated using test case templates. By combining the first and second large language models, highly accurate test cases can be generated automatically.

Benefits of technology

It improves the accuracy of test case generation, reduces manual writing time, achieves automated test case generation and high coverage, and ensures the comprehensiveness of software functional verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122261981A_ABST
    Figure CN122261981A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a test case generation method and device, electronic equipment and storage medium. The test case generation method comprises: obtaining first input information, the first input information comprising first initial software requirement information and normalization rule information; taking the first input information as the input of a first large language model to obtain first target software requirement information corresponding to the first initial software requirement information output by the first large language model; obtaining second input information, the second input information comprising a test case template corresponding to the first target software requirement information and the first initial software requirement information; taking the second input information as the input of a second large language model to obtain a first test case corresponding to the first initial software requirement information output by the second large language model. The test case generated in the embodiments of the present application can represent the physical meaning of the first initial software requirement itself, and the accuracy of the generated test case is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software technology, and in particular to a test case generation method, apparatus, electronic device, and storage medium. Background Technology

[0002] In today's rapidly developing new energy vehicle sector, the complexity and scale of vehicle ECU (Electronic Control Unit) software are constantly increasing, posing challenges to the rapid verification of software functions. The traditional ASPICE (Automotive Software Process Improvement and Capability Determination) process divides software verification into three parts: software conformance testing, system conformance testing, and vehicle testing. Software conformance testing primarily verifies the software's functional logic, typically using SIL (Software In-the-Loop) testing in a purely virtual environment.

[0003] Using the SIL (System-In-Process) testing scheme for software conformance testing allows for flexible adjustment of the boundaries of the code under test (functional group level verification, application layer level verification, etc.) and offers the advantage of high-efficiency test execution, thus it has been widely used in vehicle controller software development. However, the test cases required for testing need to be written manually. In practice, it has been found that writing software conformance test cases consumes a significant amount of time and effort. Therefore, due to limitations such as differences in the testability of software requirements and the software development project cycle, software conformance testing often fails to achieve full coverage of test code and cannot fully realize its purpose. Most outflow issues at this stage are caused by test cases that do not fully cover the software requirements. Therefore, improving the quality of test cases is a key task in improving the quality of software conformance testing.

[0004] The emergence of automated test case generation technology aims to solve this problem. In the ASPICE process, automated software qualification test case generation refers to the automatic generation of a set of software test cases according to a fixed format to verify whether the functions described in the software requirements are implemented, ensuring that the software logic can achieve the functions described in the requirements. While test cases generated using this technology can reduce the workload of manually writing test cases, it generates software test cases using an exhaustive approach based on a fixed format, resulting in lower accuracy. Summary of the Invention

[0005] In view of the above problems, this application proposes a test case generation method, apparatus, electronic device and storage medium to solve the problem of low accuracy of generated test cases.

[0006] According to one aspect of an embodiment of this application, a test case generation method is provided, the method comprising:

[0007] Obtain first input information, which includes first initial software requirements information and normalization rule information;

[0008] The first input information is used as the input of the first large language model to obtain the first target software requirement information output by the first large language model, which corresponds to the first initial software requirement information.

[0009] Obtain second input information, which includes the test case templates corresponding to the first target software requirement information and the first initial software requirement information;

[0010] The second input information is used as the input to the second large language model to obtain the first test case output by the second large language model, which corresponds to the first initial software requirement information.

[0011] Optionally, the normalization rule information includes: the mapping relationship between the natural language corresponding to the logical condition and the normalized language corresponding to the logical condition, and the mapping relationship between the natural language corresponding to the requirement description and the normalized language corresponding to the requirement description.

[0012] Optionally, the test case template includes: test input conditions, test execution steps, expected test results, and test interface information.

[0013] Optionally, before obtaining the first input information, the method further includes:

[0014] Obtain the test case template corresponding to the second initial software requirement information, and the first target test case corresponding to the second initial software requirement information;

[0015] Based on the test case template corresponding to the second initial software requirement information, generate the second test case corresponding to the second initial software requirement information.

[0016] Obtain the first similarity between the second test case and the first target test case. When the first similarity is less than a preset threshold, correct the test case template corresponding to the second initial software requirement information.

[0017] Optionally, generating second test cases corresponding to the second initial software requirements information based on the test case template corresponding to the second initial software requirements information includes:

[0018] Generate third input information, which includes the second initial software requirements information and the normalization rule information;

[0019] The third input information is used as the input to the first large language model to obtain the second target software requirement information output by the first large language model, which corresponds to the second initial software requirement information.

[0020] Generate fourth input information, which includes test case templates corresponding to the second target software requirement information and the second initial software requirement information;

[0021] The fourth input information is used as the input to the second large language model to obtain the second test case output by the second large language model, which corresponds to the second initial software requirement information.

[0022] Optionally, before obtaining the first input information, the method further includes:

[0023] Obtain the test case template corresponding to the third initial software requirement information, and the second target test case corresponding to the third initial software requirement information;

[0024] For each candidate large language model, a third test case corresponding to the third initial software requirement information is generated based on the test case template corresponding to the third initial software requirement information using the candidate large language model.

[0025] The second similarity between the second target test case and each of the third test cases is obtained respectively. The candidate large language model corresponding to the third test case with the highest second similarity is selected as the second large language model.

[0026] Optionally, the step of generating third test cases corresponding to the third initial software requirement information based on the test case template corresponding to the third initial software requirement information using the candidate large language model includes:

[0027] Generate fifth input information, which includes the third initial software requirements information and the normalization rule information;

[0028] The fifth input information is used as the input to the first large language model to obtain the third target software requirement information output by the first large language model, which corresponds to the third initial software requirement information.

[0029] Generate sixth input information, which includes the test case templates corresponding to the third target software requirement information and the third initial software requirement information;

[0030] The sixth input information is used as the input to the candidate large language model to obtain the third test case output by the candidate large language model, which corresponds to the third initial software requirement information.

[0031] According to another aspect of the embodiments of this application, a test case generation apparatus is provided, the apparatus comprising:

[0032] The first acquisition module is used to acquire first input information, which includes first initial software requirements information and normalization rule information.

[0033] The first processing module is used to take the first input information as the input of the first large language model to obtain the first target software requirement information output by the first large language model, which corresponds to the first initial software requirement information.

[0034] The second acquisition module is used to acquire second input information, which includes the first target software requirement information and the test case template corresponding to the first initial software requirement information.

[0035] The second processing module is used to take the second input information as input to the second large language model to obtain the first test case output by the second large language model corresponding to the first initial software requirement information.

[0036] Optionally, the normalization rule information includes: the mapping relationship between the natural language corresponding to the logical condition and the normalized language corresponding to the logical condition, and the mapping relationship between the natural language corresponding to the requirement description and the normalized language corresponding to the requirement description.

[0037] Optionally, the test case template includes: test input conditions, test execution steps, expected test results, and test interface information.

[0038] Optionally, the device further includes:

[0039] The third acquisition module is used to acquire the test case template corresponding to the second initial software requirement information, and the first target test case corresponding to the second initial software requirement information.

[0040] The first generation module is used to generate a second test case corresponding to the second initial software requirement information based on the test case template corresponding to the second initial software requirement information.

[0041] The correction module is used to obtain the first similarity between the second test case and the first target test case, and when the first similarity is less than a preset threshold, correct the test case template corresponding to the second initial software requirement information.

[0042] Optionally, the first generation module is specifically configured to generate third input information, which includes the second initial software requirement information and the normalization rule information; use the third input information as input to the first large language model to obtain second target software requirement information output by the first large language model corresponding to the second initial software requirement information; generate fourth input information, which includes the second target software requirement information and a test case template corresponding to the second initial software requirement information; use the fourth input information as input to the second large language model to obtain second test cases output by the second large language model corresponding to the second initial software requirement information.

[0043] Optionally, the device further includes:

[0044] The fourth acquisition module is used to acquire the test case template corresponding to the third initial software requirement information, and the second target test case corresponding to the third initial software requirement information.

[0045] The second generation module is used to generate a third test case corresponding to the third initial software requirement information for each candidate large language model, based on the test case template corresponding to the third initial software requirement information.

[0046] The selection module is used to obtain the second similarity between the second target test case and each of the third test cases, and select the candidate large language model corresponding to the third test case with the highest second similarity as the second large language model.

[0047] Optionally, the second generation module is specifically used to generate fifth input information, which includes the third initial software requirement information and the normalization rule information; to use the fifth input information as input to the first large language model to obtain the third target software requirement information output by the first large language model corresponding to the third initial software requirement information; to generate sixth input information, which includes the third target software requirement information and the test case template corresponding to the third initial software requirement information; and to use the sixth input information as input to the candidate large language model to obtain the third test case output by the candidate large language model corresponding to the third initial software requirement information.

[0048] According to another aspect of the embodiments of this application, an electronic device is provided, the electronic device including a processor and a computer-readable storage medium storing a computer program; when the computer program is executed by the processor, the processor causes the processor to perform the test case generation method as described in any of the preceding claims.

[0049] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, causes the processor to perform the test case generation method as described in any of the preceding claims.

[0050] In this embodiment, firstly, a first major language model is used to analyze and understand the first initial software requirement information and normalization rule information to obtain the first target software requirement information corresponding to the first initial software requirement information. This normalizes the first initial software requirement information and avoids inconsistent test case generation quality due to differences in the description of software requirement information. Then, a second major language model is used to analyze and understand the first target software requirement information and the test case template corresponding to the first initial software requirement information. This generates the first test case corresponding to the first initial software requirement information according to the test case template, achieving automated test case generation. Furthermore, semantic understanding analysis is performed on the first target software requirement information itself. Since the test case template is also the template corresponding to the first initial software requirement information, the generated test cases can represent the physical meaning of the first initial software requirement itself, resulting in higher accuracy.

[0051] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0052] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some drawings of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 This is a flowchart of a test case generation method according to an embodiment of this application;

[0054] Figure 2 This is a flowchart of another test case generation method according to an embodiment of this application;

[0055] Figure 3 This is a structural block diagram of a test case generation device according to an embodiment of this application;

[0056] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application;

[0057] Figure 5 This is a structural block diagram of a computer-readable storage medium according to an embodiment of this application. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0059] In the embodiments of this application, taking advantage of the powerful semantic understanding capabilities of the Large Language Model (LLM), a method is proposed to utilize the LLM for understanding software requirements information and generating test cases. Prompt information (i.e., input information) is generated by inputting relevant contextual information into a prompt template, and then the LLM generates test cases through a dialogue.

[0060] On the one hand, the first initial software requirement information is normalized using the first major language model and transformed into the first target software requirement information that meets the requirements. This ensures that the first target software requirement information obtained after normalization has clear syntax and semantics, thereby eliminating ambiguity and inconsistency in the description. Therefore, normalization can greatly help the subsequent understanding and processing of the second major language model.

[0061] On the other hand, the second major language model is used to perform semantic understanding on the test case templates corresponding to the first target software requirement information and the first initial software requirement information obtained after normalization, thereby generating more accurate and standardized test cases and realizing automated test case development.

[0062] The first and second large language models mentioned in the embodiments of this application can be constructed using the structure of any open-source large language model such as GPT (Generative Pre-trained Transformer). The structures of the first and second large language models can be the same or different, and this application does not impose any restrictions on this.

[0063] The test case generation method provided in this application can be applied to any suitable electronic device, such as terminal devices, servers, etc.

[0064] Reference Figure 1 The diagram shows a flowchart of a test case generation method according to an embodiment of this application.

[0065] like Figure 1 As shown, the test case generation method may include the following steps:

[0066] Step 101: Obtain first input information, which includes first initial software requirements information and normalization rule information.

[0067] The first initial software requirement information refers to the initial software requirement information to be processed, and the purpose is to generate corresponding test cases based on the first initial software requirement information.

[0068] Initial software requirements information (IPI) is software requirements described in natural language. IPI can be created after thorough communication with the software development team to fully understand the system's functional and non-functional requirements, especially its behavior under different conditions. The specific content of IPI can be tailored to actual needs; this embodiment does not impose any limitations on this.

[0069] Taking the initial software requirements information as the fault diagnosis software requirements information as an example, the interaction between the controller and the air conditioning system under different states can be analyzed to generate the initial fault diagnosis software requirements information. For example, one piece of information could be "If the controller is in the DTC (Diagnostic Trouble Codes) control settings of the diagnostic instrument, the fault diagnosis status of the air conditioning outlet temperature is inactive."

[0070] Normalization rule information refers to the normalization rules that need to be followed when converting initial software requirements information described in natural language into target software requirements information described in normalized language. Normalization rule information can be set according to actual needs and experience; this embodiment does not impose any restrictions on it.

[0071] For example, the initial software requirements information may include, but is not limited to, logical conditions and requirement descriptions. Logical conditions refer to the information in the initial software requirements information that represents logical relationships, and requirement descriptions refer to the requirement content in the initial software requirements information.

[0072] Taking the initial software requirements information as fault diagnosis software requirements information as an example, one of the pieces of information is "If the controller is in the DTC control setting of the diagnostic instrument, then the fault diagnosis status of the air conditioner outlet temperature is not activated". In this case, "If..., then..." is the logical condition, and "The controller is in the DTC control setting of the diagnostic instrument" and "The fault diagnosis status of the air conditioner outlet temperature is not activated" are the requirement descriptions.

[0073] Accordingly, the normalization rule information includes: the mapping relationship between the natural language corresponding to the logical condition and the normalized language corresponding to the logical condition, and the mapping relationship between the natural language corresponding to the requirement description and the normalized language corresponding to the requirement description. The specific content of the normalization rule information can be processed according to actual needs; this embodiment does not impose any restrictions on this.

[0074] In practical applications, software requirements with the same substantive meaning may be described in different natural language. Therefore, by statistically analyzing a large number of possible natural language descriptions, normalization rules can be configured to ensure that these normalization rules cover all possible requirement scenarios.

[0075] For example, the natural language corresponding to logical conditions, such as "if...then...", "if...then...", "if...then...", etc., can all be mapped to the normalized language corresponding to the logical condition, such as "if...then..."; the natural language corresponding to logical conditions, such as "when...is satisfied, then execute...", "when...is satisfied, then execute...", etc., can all be mapped to the normalized language corresponding to the logical condition, such as "when...then...", etc.

[0076] For example, the natural language corresponding to the requirement description, such as "the controller is in the DTC control setting of the diagnostic instrument" or "the controller is in the DTC control setting state of the diagnostic instrument", can be mapped to the normalized language corresponding to the requirement description, such as "DiagcDTCCtrl=1"; the natural language corresponding to the requirement description, such as "the fault diagnosis state of the air conditioner outlet temperature is not activated" or "the fault diagnosis state of the air conditioner outlet temperature will not be activated", can be mapped to the normalized language corresponding to the requirement description, such as "FrtACTSnsrErr_enum==NotCarryOut", and so on.

[0077] After obtaining the initial software requirements information and normalization rule information, the system further obtains the first input information, which includes the initial software requirements information and normalization rule information.

[0078] In implementation, a first prompt template corresponding to the first major language model can be set. This first prompt template can include fields for filling in initial software requirement information and fields for filling in normalization rule information. The initial software requirement information is filled into the fields for initial software requirement information in the first prompt template, and the normalization rule information is filled into the fields for normalization rule information in the first prompt template, thus obtaining the first input information. It should be noted that the first prompt template can also contain other content, such as first guidance information to instruct the first major language model to convert the initial software requirement information into target software requirement information based on the normalization rule information, etc. This embodiment does not impose any restrictions on this.

[0079] Step 102: Use the first input information as input to the first large language model to obtain the first target software requirement information output by the first large language model, which corresponds to the first initial software requirement information.

[0080] The first input information is used as the input to the first large language model. The first large oracle model performs a full semantic understanding of the first initial software requirement information and the normalization rule information, thereby outputting the first target software requirement information corresponding to the first initial software requirement information.

[0081] Taking the first initial software requirement information as the fault diagnosis software requirement information as an example, one of the pieces of information is "If the controller is in the DTC control setting of the diagnostic instrument, the fault diagnosis status of the air conditioner outlet temperature is not activated". After analysis by the first large language model, the first target software requirement information corresponding to the first initial software requirement information can be "IF DiagcDTCCtrl=1THEN FrtACTSnsrErr_enum==NotCarryOut".

[0082] In implementation, after obtaining the first target software requirement information output by the first large language model that corresponds to the first initial software requirement information, the first target software requirement information can be manually confirmed and adjusted to further improve the accuracy of the first target software requirement information.

[0083] Step 103: Obtain second input information, which includes the test case templates corresponding to the first target software requirement information and the first initial software requirement information.

[0084] In this embodiment, test case templates can be constructed in advance by analyzing a large amount of initial software requirement information. The test case templates corresponding to different initial software requirement information can be the same or different, depending on the actual situation of the initial software requirement information; this embodiment does not impose any restrictions on this. The test case templates are stored in a database, along with the correspondence between the test case templates and the initial software requirement information, so that the corresponding test case template can be retrieved based on the initial software requirement information.

[0085] For example, a test case template may include, but is not limited to: test input conditions, test execution steps, expected test results, and test interface information. This information allows for accurate representation of the information required in the test case.

[0086] Input conditions indicate the conditions under which the test should be performed. For example, input conditions could be "DiagcDTCCtrl=1", "Vehicle is powered on", "User has successfully logged into the system", "The system already has valid data", and so on.

[0087] The execution steps refer to the specific operational steps of the test. For example, the execution steps could be "detecting the fault status of the air conditioner outlet temperature," and so on.

[0088] The expected result represents the goal of a successful test. For example, the expected result would be "the status should be inactive," and so on.

[0089] The test interface information indicates the interface corresponding to the test, thereby ensuring that the test case template can adapt to tests of different interface types and providing flexible field definitions.

[0090] After obtaining the first initial software requirement information, the test case template corresponding to the first initial software requirement information is queried, and second input information containing the first target software requirement information and the test case template corresponding to the first initial software requirement information is further obtained.

[0091] In implementation, a second prompt template corresponding to the second major language model can be set. This second prompt template can include fields for filling in target software requirement information and fields for filling in test case templates. The first target software requirement information is filled into the field for filling in target software requirement information in the second prompt template, and the test case template corresponding to the first initial software requirement information is filled into the field for filling in test case templates in the second prompt template, thus obtaining the second input information. It should be noted that the second prompt template can also contain other content, such as second guidance information to instruct the second major language model to generate test cases based on the target software requirement information and the test case template. This embodiment does not impose any limitations on this.

[0092] Step 104: Use the second input information as input to the second large language model to obtain the first test case output by the second large language model that corresponds to the first initial software requirement information.

[0093] The second input information is used as input to the second language model. The second language model performs a full semantic understanding of the test case templates corresponding to the first target software requirement information and the first initial software requirement information, thereby outputting the first test case corresponding to the first initial software requirement information.

[0094] In this embodiment, firstly, a first major language model is used to analyze and understand the first initial software requirement information and normalization rule information to obtain the first target software requirement information corresponding to the first initial software requirement information. This normalizes the first initial software requirement information and avoids inconsistent test case generation quality due to differences in the description of software requirement information. Then, a second major language model is used to analyze and understand the first target software requirement information and the test case template corresponding to the first initial software requirement information. This generates the first test case corresponding to the first initial software requirement information according to the test case template, achieving automated test case generation. Furthermore, semantic understanding analysis is performed on the first target software requirement information itself. Since the test case template is also the template corresponding to the first initial software requirement information, the generated test cases can represent the physical meaning of the first initial software requirement itself, resulting in higher accuracy.

[0095] In one alternative implementation, for the test case templates already stored in the database, initial software requirement information for optimizing the test case templates can be obtained, referred to as the second initial software requirement information. Furthermore, target test cases corresponding to the second initial software requirement information need to be written, referred to as the first target test cases, as the basis for optimizing the test case templates.

[0096] For example, before obtaining the first input information, the method may further include: obtaining a test case template corresponding to the second initial software requirement information, and a first target test case corresponding to the second initial software requirement information; generating a second test case corresponding to the second initial software requirement information based on the test case template; obtaining a first similarity between the second test case and the first target test case; and correcting the test case template corresponding to the second initial software requirement information when the first similarity is less than a preset threshold. This method can further improve the accuracy of the test case template, thereby ensuring the effectiveness and operability of the test case template in practical applications.

[0097] Specifically, the process of generating a second test case corresponding to the second initial software requirement information based on the test case template corresponding to the second initial software requirement information may include: generating third input information, the third input information including the second initial software requirement information and the normalization rule information; using the third input information as input to the first large language model to obtain the second target software requirement information output by the first large language model corresponding to the second initial software requirement information; generating fourth input information, the fourth input information including the second target software requirement information and the test case template corresponding to the second initial software requirement information; using the fourth input information as input to the second large language model to obtain the second test case output by the second large language model corresponding to the second initial software requirement information. The specific process of each step here is similar to steps 101 to 104 above, and can be referred to in detail for steps 101 to 104. This embodiment will not be discussed in detail here.

[0098] Specifically, the process of obtaining the first similarity between the second test case and the first target test case can be implemented using any applicable similarity calculation model, such as a similarity calculation model based on Transformer. The second test case and the first target test case are input into the similarity calculation model. The similarity calculation model analyzes and compares the second test case and the first target test case, and can output the first similarity between the two. The specific process can be handled based on practical experience, and will not be discussed in detail in this embodiment.

[0099] The first similarity between the second test case and the first target test case characterizes the degree of difference between them. A smaller first similarity indicates a greater difference between the two test cases. Therefore, when the first similarity is less than a preset threshold, the test case template corresponding to the second initial software requirement information can be modified. In implementation, when the first similarity is less than the preset threshold, a prompt message can be issued to remind relevant personnel to modify the test case template corresponding to the second initial software requirement information.

[0100] In one alternative implementation, to further improve the accuracy of the generated test cases, multiple candidate large language models can be compared, and the candidate large language model with the highest accuracy can be selected as the second large language model. Initial software requirement information for optimizing the second large language model can be obtained in advance, referred to as the third initial software requirement information, and target test cases corresponding to the third initial software requirement information need to be written, referred to as the second target test cases.

[0101] For example, before obtaining the first input information, the method may further include: obtaining a test case template corresponding to the third initial software requirement information, and a second target test case corresponding to the third initial software requirement information; for each candidate large language model, using the candidate large language model and based on the test case template corresponding to the third initial software requirement information, generating a third test case corresponding to the third initial software requirement information; obtaining a second similarity between the second target test case and each of the third test cases, and selecting the candidate large language model corresponding to the third test case with the highest second similarity as the second large language model. The second large language model obtained in this way has higher accuracy.

[0102] Specifically, using the candidate large language model and based on the test case template corresponding to the third initial software requirement information, generating a third test case corresponding to the third initial software requirement information may include: generating fifth input information, the fifth input information including the third initial software requirement information and the normalization rule information; using the fifth input information as input to the first large language model to obtain the third target software requirement information output by the first large language model corresponding to the third initial software requirement information; generating a sixth input information, the sixth input information including the third target software requirement information and the test case template corresponding to the third initial software requirement information; using the sixth input information as input to the candidate large language model to obtain the third test case output by the candidate large language model corresponding to the third initial software requirement information. The specific process of each step here is similar to steps 101 to 104 above, and can be referred to in detail for steps 101 to 104. This embodiment will not be discussed in detail here.

[0103] Specifically, the process of obtaining the second similarity between the second target test case and the third test case for any given third test case can be implemented using any applicable similarity calculation model, such as a Transformer-based similarity calculation model. The second target test case and the third test case are input into the similarity calculation model, which analyzes and compares them to output the second similarity between them. The specific process can be handled based on practical experience, and will not be discussed in detail in this embodiment.

[0104] The second similarity between the second target test case and the third test case can characterize the degree of difference between the second target test case and the third test case. The smaller the second similarity, the greater the degree of difference between the second target test case and the third test case. Therefore, the candidate large language model corresponding to the third test case with the highest second similarity is selected as the second large language model.

[0105] Reference Figure 2 The diagram shows a flowchart of another test case generation method according to an embodiment of this application.

[0106] like Figure 2 As shown, the test case generation method may include: constructing a test case template, which includes test input conditions, test execution steps, expected test results, and test interface information; generating first input information based on first initial software requirement information and normalization rule information; calling a first large language model; using the first large language model to generate first target software requirement information corresponding to the first initial software requirement information based on the first input information; manually verifying the first target software requirement information; generating second input information based on the test case template corresponding to the first initial software requirement information and the verified first target software requirement information; calling a second large language model; using the second large language model to generate first test cases corresponding to the first initial software requirement information based on the second input information; constructing an automated testing environment; calling a test execution tool to automatically execute the test cases; and confirming the test results.

[0107] When building an automated testing environment, the system can set up and configure the environment, including the testing framework, tools, and test datasets, and integrate the generated test cases into it. When the automated test execution tool is invoked to execute test cases, it records the test results and generates a test report. During test result confirmation, testers review the test report, analyze passed and failed test cases, record and report any issues found, and collaborate with the development team to resolve them. After a fix, the above steps are repeated to ensure that the problem is resolved without introducing new issues, thus confirming the test results.

[0108] In this embodiment, the process of transforming initial software requirements into target software requirements information and then generating test cases is normalized. This facilitates collaboration among different teams within an enterprise, avoids inconsistent test case quality due to differences in software requirement descriptions, significantly reduces the time spent manually writing test cases, and accelerates the testing process through automated test case generation and execution. High test case coverage is achieved through model optimization, reducing omissions. Furthermore, the feedback and adjustment mechanisms continuously improve the accuracy and effectiveness of generated test cases, ensuring test quality.

[0109] Reference Figure 3 The diagram shows a structural block diagram of a test case generation device according to an embodiment of this application.

[0110] like Figure 3 As shown, the test case generation device may include the following modules:

[0111] The first acquisition module 301 is used to acquire first input information, which includes first initial software requirement information and normalization rule information.

[0112] The first processing module 302 is used to take the first input information as the input of the first large language model to obtain the first target software requirement information output by the first large language model, which corresponds to the first initial software requirement information.

[0113] The second acquisition module 303 is used to acquire second input information, which includes the first target software requirement information and the test case template corresponding to the first initial software requirement information.

[0114] The second processing module 304 is used to take the second input information as input to the second large language model to obtain the first test case output by the second large language model corresponding to the first initial software requirement information.

[0115] Optionally, the normalization rule information includes: the mapping relationship between the natural language corresponding to the logical condition and the normalized language corresponding to the logical condition, and the mapping relationship between the natural language corresponding to the requirement description and the normalized language corresponding to the requirement description.

[0116] Optionally, the test case template includes: test input conditions, test execution steps, expected test results, and test interface information.

[0117] Optionally, the device further includes:

[0118] The third acquisition module is used to acquire the test case template corresponding to the second initial software requirement information, and the first target test case corresponding to the second initial software requirement information.

[0119] The first generation module is used to generate a second test case corresponding to the second initial software requirement information based on the test case template corresponding to the second initial software requirement information.

[0120] The correction module is used to obtain the first similarity between the second test case and the first target test case, and when the first similarity is less than a preset threshold, correct the test case template corresponding to the second initial software requirement information.

[0121] Optionally, the first generation module is specifically configured to generate third input information, which includes the second initial software requirement information and the normalization rule information; use the third input information as input to the first large language model to obtain second target software requirement information output by the first large language model corresponding to the second initial software requirement information; generate fourth input information, which includes the second target software requirement information and a test case template corresponding to the second initial software requirement information; use the fourth input information as input to the second large language model to obtain second test cases output by the second large language model corresponding to the second initial software requirement information.

[0122] Optionally, the device further includes:

[0123] The fourth acquisition module is used to acquire the test case template corresponding to the third initial software requirement information, and the second target test case corresponding to the third initial software requirement information.

[0124] The second generation module is used to generate a third test case corresponding to the third initial software requirement information for each candidate large language model, based on the test case template corresponding to the third initial software requirement information.

[0125] The selection module is used to obtain the second similarity between the second target test case and each of the third test cases, and select the candidate large language model corresponding to the third test case with the highest second similarity as the second large language model.

[0126] Optionally, the second generation module is specifically used to generate fifth input information, which includes the third initial software requirement information and the normalization rule information; to use the fifth input information as input to the first large language model to obtain the third target software requirement information output by the first large language model corresponding to the third initial software requirement information; to generate sixth input information, which includes the third target software requirement information and the test case template corresponding to the third initial software requirement information; and to use the sixth input information as input to the candidate large language model to obtain the third test case output by the candidate large language model corresponding to the third initial software requirement information.

[0127] In this embodiment, firstly, a first major language model is used to analyze and understand the first initial software requirement information and normalization rule information to obtain the first target software requirement information corresponding to the first initial software requirement information. This normalizes the first initial software requirement information and avoids inconsistent test case generation quality due to differences in the description of software requirement information. Then, a second major language model is used to analyze and understand the first target software requirement information and the test case template corresponding to the first initial software requirement information. This generates the first test case corresponding to the first initial software requirement information according to the test case template, achieving automated test case generation. Furthermore, semantic understanding analysis is performed on the first target software requirement information itself. Since the test case template is also the template corresponding to the first initial software requirement information, the generated test cases can represent the physical meaning of the first initial software requirement itself, resulting in higher accuracy.

[0128] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0129] In embodiments of this application, an electronic device is also provided. This electronic device may include a processor and a computer-readable storage medium storing a computer program; when the computer program is executed by the processor, it causes the processor to perform the test case generation method of any of the above embodiments.

[0130] Reference Figure 4 This diagram illustrates a structural block diagram of an electronic device according to an embodiment of this application. Figure 4 As shown, the electronic device 11 includes a processor 111 and a computer-readable storage medium 112, on which a computer program 1121 is stored.

[0131] The processor 111 is used to execute the computer program 1121 stored on the computer-readable storage medium 112. When executing the computer program 1121, the processor 111 implements the test case generation method of any of the above embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0132] The processor 111 mentioned above may include, but is not limited to: a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0133] The aforementioned computer-readable storage medium 112 may include, but is not limited to: read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), electronically erasable programmable read-only memory (EEPROM), hard disk, floppy disk, flash memory, etc.

[0134] In embodiments of this application, a computer-readable storage medium is also provided, on which a computer program is stored, which can be executed by a processor of an electronic device, and when the computer program is executed by the processor, the processor performs the test case generation method as described in any of the above embodiments.

[0135] Reference Figure 5 This diagram illustrates a structural block diagram of a computer-readable storage medium according to an embodiment of this application. Figure 5 As shown, a computer program 211 is stored on a computer-readable storage medium 21. When the computer program 211 is executed by a processor, it causes the processor to perform the test case generation method as described in any of the above embodiments, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0136] The various embodiments in this specification are related to each other and are described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other.

[0137] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the relevant data protection laws and regulations of the locality and with authorization from the owner of the relevant device.

[0138] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0139] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0140] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

[0141] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0142] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0143] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0144] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0145] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0146] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. In summary, the content of this specification should not be construed as a limitation of this application.

Claims

1. A test case generation method, characterized in that, The method includes: Obtain first input information, which includes first initial software requirements information and normalization rule information; The first input information is used as the input of the first large language model to obtain the first target software requirement information output by the first large language model, which corresponds to the first initial software requirement information. Obtain second input information, which includes the test case templates corresponding to the first target software requirement information and the first initial software requirement information; The second input information is used as the input to the second large language model to obtain the first test case output by the second large language model, which corresponds to the first initial software requirement information.

2. The method according to claim 1, characterized in that, The normalization rule information includes: the mapping relationship between the natural language corresponding to the logical condition and the normalized language corresponding to the logical condition, and the mapping relationship between the natural language corresponding to the requirement description and the normalized language corresponding to the requirement description.

3. The method according to claim 1, characterized in that, The test case template includes: test input conditions, test execution steps, expected test results, and test interface information.

4. The method according to claim 1, characterized in that, Before obtaining the first input information, it also includes: Obtain the test case template corresponding to the second initial software requirement information, and the first target test case corresponding to the second initial software requirement information; Based on the test case template corresponding to the second initial software requirement information, generate the second test case corresponding to the second initial software requirement information. Obtain the first similarity between the second test case and the first target test case. When the first similarity is less than a preset threshold, correct the test case template corresponding to the second initial software requirement information.

5. The method according to claim 4, characterized in that, The step of generating second test cases corresponding to the second initial software requirements information based on the test case template includes: Generate third input information, which includes the second initial software requirements information and the normalization rule information; The third input information is used as the input to the first large language model to obtain the second target software requirement information output by the first large language model, which corresponds to the second initial software requirement information. Generate fourth input information, which includes test case templates corresponding to the second target software requirement information and the second initial software requirement information; The fourth input information is used as the input to the second large language model to obtain the second test case output by the second large language model, which corresponds to the second initial software requirement information.

6. The method according to claim 1, characterized in that, Before obtaining the first input information, it also includes: Obtain the test case template corresponding to the third initial software requirement information, and the second target test case corresponding to the third initial software requirement information; For each candidate large language model, a third test case corresponding to the third initial software requirement information is generated based on the test case template corresponding to the third initial software requirement information using the candidate large language model. The second similarity between the second target test case and each of the third test cases is obtained respectively. The candidate large language model corresponding to the third test case with the highest second similarity is selected as the second large language model.

7. The method according to claim 6, characterized in that, The step of generating third test cases corresponding to the third initial software requirements information using the candidate large language model and based on the test case template corresponding to the third initial software requirements information includes: Generate fifth input information, which includes the third initial software requirements information and the normalization rule information; The fifth input information is used as the input to the first large language model to obtain the third target software requirement information output by the first large language model, which corresponds to the third initial software requirement information. Generate sixth input information, which includes the test case templates corresponding to the third target software requirement information and the third initial software requirement information; The sixth input information is used as the input to the candidate large language model to obtain the third test case output by the candidate large language model, which corresponds to the third initial software requirement information.

8. A test case generation device, characterized in that, The device includes: The first acquisition module is used to acquire first input information, which includes first initial software requirements information and normalization rule information. The first processing module is used to take the first input information as the input of the first large language model to obtain the first target software requirement information output by the first large language model, which corresponds to the first initial software requirement information. The second acquisition module is used to acquire second input information, which includes the first target software requirement information and the test case template corresponding to the first initial software requirement information. The second processing module is used to take the second input information as input to the second large language model to obtain the first test case output by the second large language model corresponding to the first initial software requirement information.

9. An electronic device, characterized in that, The electronic device includes a processor and a computer-readable storage medium on which a computer program is stored; When the computer program is executed by the processor, the processor performs the test case generation method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the test case generation method as described in any one of claims 1 to 7.