Test case generation model training method and related device
Through the test case generation model training method, efficient and accurate test cases are automatically generated, solving the problem of inefficient human writing and achieving full coverage and accuracy of application testing.
Patent Information
- Application Number
- CN202411899932.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-03-18
AI Technical Summary
In the prior art, test cases need to be written manually, which is inefficient, and the generated test cases may lack the necessary objects, resulting in application testing failure.
Provide a test case generation model training method. By obtaining preset sample scripts and training sets, inputting them into the test case generation model, generating multiple test cases, and optimizing the model to improve the generation quality of test cases by analyzing the cause of test failure.
It realizes automatic generation of test cases without human writing, improves the efficiency and accuracy of test cases generation, and reduces the test failure rate caused by test case problems.
Smart Images

Figure CN119645879A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a test case generation model training method and related devices. Background Art
[0002] As software technology develops, applications become more and more complex. Applications are tested after they are developed or updated, and if they pass the test, the developed or updated applications are released.
[0003] In the related art, test cases for testing application programs need to be written manually, which is inefficient. Summary of the invention
[0004] In view of the above problems, the present application provides a test case generation model training method and related devices to achieve the purpose of automatically generating test cases. The specific scheme is as follows:
[0005] The first aspect of the present application provides a test case generation model training method, comprising:
[0006] Obtaining a preset sample script, a first training set, and a training annotation test case corresponding to the first training set; the first training set includes definition information corresponding to a plurality of interfaces and dependency relationships between the plurality of interfaces;
[0007] Inputting the sample script and the first training set into a test case generation model, and obtaining a plurality of first test cases through the test case generation model;
[0008] The test case generation model is obtained by taking the sample script, the definition information corresponding to the plurality of sample interfaces, and the dependency relationship between the plurality of sample interfaces as input, and taking the sample annotated test case as the training target;
[0009] Obtaining a test failure reason of a second test case, where the second test case is a test case in which the application program test fails due to a lack of an object among the plurality of first test cases; the test failure reason includes the object and the role of the object in the second test case;
[0010] Based on the test failure reason of the second test case, obtain a first Prompt word;
[0011] The first Prompt word and the first training set are taken as input, and the training annotated test cases of the first training set are taken as training targets to train the test case generation model.
[0012] In a possible implementation, the step of taking the first Prompt word and the first training set as input, taking the training annotated test cases of the first training set as training targets, and training the test case generation model includes:
[0013] Obtaining a first ratio of the number of the second test cases to the number of the first test cases;
[0014] Inputting the first Prompt word and the first training set into the test case generation model, and obtaining a plurality of third test cases through the test case generation model;
[0015] Obtaining a target number of fourth test cases among the plurality of third test cases; the fourth test case is a test case in which the application program test fails due to lack of an object;
[0016] determining a second ratio of the target number to the number of the third test cases;
[0017] If the second ratio is higher than or equal to the first ratio, based on the first ratio, the second ratio, and the role of the object missing from the fourth test case in the fourth test case, obtaining a second Prompt word;
[0018] The second Prompt word and the first training set are taken as input, and the training annotated test cases of the second training set are taken as training targets to train the test case generation model.
[0019] In a possible implementation, the method further includes:
[0020] If the second ratio is lower than the first ratio, obtaining a second training set and training annotated test cases corresponding to the second training set; the second training set includes definition information corresponding to a plurality of interfaces and dependency relationships between the plurality of interfaces;
[0021] The first Prompt word and the second training set are taken as input, and the training annotated test cases of the second training set are taken as training targets to train the test case generation model.
[0022] In a possible implementation, acquiring the first training set includes:
[0023] Inputting the Swagger interface document into a pre-built interface information analysis model, and obtaining the first training set through the interface information analysis model;
[0024] Among them, the interface information analysis model is obtained by training with a sample Swagger interface document as input and a sample annotation training set as a training target. The sample annotation training set includes the sample Swagger interface document, including definition information corresponding to multiple interfaces and the dependency relationship between multiple interfaces.
[0025] In a possible implementation, the method further includes:
[0026] Obtaining a target interface of the application that is not tested;
[0027] Based on the target interface, obtain a third Prompt prompt word;
[0028] The third Prompt word and the first training set are taken as input, and the training annotated test cases corresponding to the first training set are taken as training targets to train the test case generation model.
[0029] A second aspect of the present application provides a test case generation model training device, comprising:
[0030] A first acquisition module is used to acquire a preset sample script, a first training set, and a training annotation test case corresponding to the first training set; the first training set includes definition information corresponding to a plurality of interfaces and dependency relationships between the plurality of interfaces;
[0031] A second acquisition module, used for inputting the sample script and the first training set into a test case generation model, and acquiring a plurality of first test cases through the test case generation model;
[0032] The test case generation model is obtained by taking the sample script, the definition information corresponding to the plurality of sample interfaces, and the dependency relationship between the plurality of sample interfaces as input, and taking the sample annotated test case as the training target;
[0033] A third acquisition module is used to obtain the test failure reason of a second test case, where the second test case is a test case in which the application test fails due to a lack of an object among the plurality of first test cases; the test failure reason includes the object and the role of the object in the second test case;
[0034] A fourth acquisition module, configured to acquire a first Prompt word based on the test failure reason of the second test case;
[0035] The first training module is used to take the first Prompt word and the first training set as input, take the training annotated test cases of the first training set as training targets, and train the test case generation model.
[0036] In a possible implementation, the first training module includes:
[0037] A first acquiring unit, configured to acquire a first ratio of the number of the second test cases to the number of the first test cases;
[0038] A second acquisition unit, configured to input the first Prompt word and the first training set into the test case generation model, and acquire a plurality of third test cases through the test case generation model;
[0039] A third acquisition unit, configured to acquire a target number of fourth test cases from among the plurality of third test cases; the fourth test case being a test case in which the application program test fails due to a lack of an object;
[0040] a first determining unit, configured to determine a second ratio of the target number to the number of the third test cases;
[0041] A fourth acquisition unit is configured to acquire a second Prompt word based on the first ratio, the second ratio, and the role of the object missing from the fourth test case in the fourth test case if the second ratio is higher than or equal to the first ratio;
[0042] The first training unit is used to take the second Prompt word and the first training set as input, take the training annotated test cases of the second training set as training targets, and train the test case generation model.
[0043] The third aspect of the present application provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the test case generation model training method of the above-mentioned first aspect or any implementation method of the first aspect.
[0044] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0045] The memory is used to store computer programs;
[0046] The processor is used to execute the computer program so that the electronic device can implement the test case generation model training method of the above-mentioned first aspect or any implementation method of the first aspect.
[0047] A fifth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can generate a test case model training method according to the above-mentioned first aspect or any implementation of the first aspect.
[0048] By means of the above technical scheme, the present application provides a test case generation model training method, obtaining a preset sample script, a first training set, and a training annotated test case corresponding to the first training set; inputting the sample script and the first training set into the test case generation model, and obtaining multiple first test cases through the test case generation model; although the test case generation model has been trained, the first test case generated by the test case generation model may not be accurate, such as lacking some necessary objects. In order to detect whether the first test case generated by the test case generation model lacks some necessary objects, the first test case can be used to test the application. Determine the second test case in the first test case that failed the test because the test case has an error. Obtain the test failure reason of the second test case; based on the test failure reason of the second test case, obtain the first Prompt prompt word; the first Prompt prompt word provides a clear optimization goal and specific improvement measures for the test case generation model, aiming to guide the test case generation model to improve the generation quality of the test case through learning and adjustment. Therefore, the test case generation model obtained by retraining with the first Prompt prompt word is more accurate, and the test case is obtained by the test case generation model, which improves efficiency without manual writing. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0050] Figure 1 A schematic diagram of a system architecture provided for this application;
[0051] Figure 2 A schematic diagram of an optional hardware structure of the terminal 100 provided in this application;
[0052] Figure 3 A schematic diagram of the structure of the first server 200 provided in this application;
[0053] Figure 4 A flowchart of a test case generation model training method provided in this application;
[0054] Figure 5 A schematic diagram of the structure of a test case generation model training device provided in this application;
[0055] Figure 6 A schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION
[0056] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0057] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0058] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0059] See also Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a terminal 100, a first server 200 and a second server 300. The first server 200 may include one or more servers ( Figure 1 In the example of including one server), the first server 200 can provide the method provided in the embodiment of the present application for one or more terminals.
[0060] Among them, an application or a web page can be installed on the terminal 100, and the above application and web page can provide an interface. The terminal 100 can receive relevant parameters entered by the user on the interface, such as determining the application to be tested, and send the above parameters to the first server 200. The first server 200 can obtain processing results based on the received parameters and return the processing results to the terminal 100.
[0061] Exemplarily, the first server 200 runs a test case generation model that needs to be trained.
[0062] Exemplarily, the second server 300 runs an application to be tested; the first server 200 can obtain the test result for the application and the test failure reasons for each test case for the application from the second server 300.
[0063] Exemplarily, the first server 200 and the second server 300 may be the same server or different servers.
[0064] It should be understood that in some optional implementations, the terminal 100 can also complete the action of interacting with the second server 300 based on the received parameters to obtain the processing result by itself without the cooperation of the first server, and the embodiments of the present application are not limited.
[0065] Next describe Figure 1 The product form of the mid-terminal 100;
[0066] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any limitation on this.
[0067] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.
[0068] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 This is merely an example of a terminal and does not constitute a limitation on the terminal. The terminal may include more or fewer components than shown in the figure, or a combination of certain components, or different components.
[0069] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the terminal. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0070] Among them, the input device 132 can receive input data and the like.
[0071] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display and / or playback of any multimedia file. In the embodiment of the present application, the display unit 140 may be used to display interfaces, processing results, etc.
[0072] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.
[0073] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.
[0074] Among them, the memory 120 can be used to store software codes related to the test case generation model training method, the processor 170 can execute the steps of the test case generation model training method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to implement corresponding functions.
[0075] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0076] In this embodiment of the present application, the RF unit 110 can send data to the first server 200 and receive a processing result sent by the first server 200.
[0077] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0078] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0079] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .
[0080] Although not shown, the terminal 100 may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 In the terminal 100 shown.
[0081] Next describe Figure 1 The product form of the first server 200;
[0082] Figure 3 A structural diagram of a first server 200 is provided, such as Figure 3 As shown, the first server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0083] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0084] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0085] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0086] Among them, the memory 204 can be used to store software codes related to the test case generation model training method, the processor 202 can execute the steps of the test case generation model training method of the chip, and can also schedule other units to implement corresponding functions.
[0087] It should be understood that the above-mentioned terminal 100 and the first server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and the first server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0088] Reference Figure 4 , Figure 4 A flow chart of a test case generation model training method provided in an embodiment of the present application, such as Figure 4 As shown, a test case generation model training method provided in an embodiment of the present application may include steps S401 to S405, and these steps are described in detail below.
[0089] Step S401: obtaining a preset sample script, a first training set, and training annotated test cases corresponding to the first training set; the first training set includes definition information corresponding to a plurality of interfaces and dependency relationships between the plurality of interfaces.
[0090] Exemplarily, the interface definition information includes, but is not limited to: path, method (GET, POST, etc.), parameters, structure of request body and response body, etc.
[0091] The following example illustrates the dependency relationship between multiple interfaces.
[0092] Exemplarily, the dependency relationship between multiple interfaces is described below with examples.
[0093] Assume that the number of multiple interfaces is 5, and the 5 interfaces are: Get user list interface GET / users, Get product list interface GET / products, Create new product interface POST / products, Create new order interface POST / orders, Get order details interface based on ID GET / orders / {orderId}. Among them, Create new order interface POST / orders may depend on Get product list interface GET / products and Get user list interface GET / users, because orders can only be created with specific users and products.
[0094] It is understandable that the first training set is known, so the training annotated test cases corresponding to the first training set can be obtained. The training annotated test cases are test cases obtained using the first training set.
[0095] For example, a template is one or a group of exemplary test cases. The template provides a basic framework for how to construct and execute tests. A template usually includes the following elements:
[0096] Interface information: The sample script specifies the details of the specific interface to be tested, such as the HTTP method (GET, POST, PUT, DELETE, etc.), the URL or path of the interface; Request parameters: The sample script contains the parameters required to construct the request, which may be path parameters, query parameters, header information, or data in the request body. Expected results: The sample script defines the expected results after executing the test, which can be a status code, the data structure and content in the response body, or a specific error message; Test steps: The sample script may contain a series of steps to instruct the automated testing tool on how to perform the test; Authentication information: If the interface requires authentication, the sample script includes authentication information, such as API keys, tokens, or usernames and passwords; Environment settings: The sample script contains instructions for setting up the test environment, such as the initialization state of the database or the conditions that need to be met before testing; Test data: The sample script contains or references test data, which is used to simulate requests in real scenarios. Assertions: The sample script contains assertions to verify whether the response meets the expected results.
[0097] The purpose of the sample scripts is to provide a reproducible test pattern that can be executed by automated testing tools.
[0098] The following example illustrates the sample script. The following example uses the sample script of the REST API:
[0099] json
[0100] {
[0101] "apiEndpoint": "https: / / api.example.com / users",
[0102] "method": "POST",
[0103] "headers": {
[0104] "Content-Type": "application / json",
[0105] "Authorization": "Bearer {access_token}"
[0106] },
[0107] "body": {
[0108] "name": "John Doe",
[0109] "email": "john.doe@example.com"
[0110] },
[0111] "expectedStatusCode": 201,
[0112] "expectedResponse": {
[0113] "id": "{user_id}",
[0114] "name": "John Doe",
[0115] "email": "john.doe@example.com"}}.
[0116] The sample script above includes the URL (Uniform Resource Locator) of the interface, the request method, the header information, the request body, the expected status code, and the expected response body. Such a sample script can be used by the automated testing framework to generate and execute test cases.
[0117] Step S402: input the sample script and the first training set into a test case generation model, and obtain a plurality of first test cases through the test case generation model.
[0118] The test case generation model is obtained by taking the sample script, definition information corresponding to a plurality of sample interfaces, and dependency relationships between the plurality of sample interfaces as inputs, and taking sample annotated test cases as training targets.
[0119] Exemplarily, the sample annotated test case is obtained based on the sample script, definition information corresponding to a plurality of sample interfaces, and dependency relationships between the plurality of sample interfaces.
[0120] The process of training the test case generation model involves at least one of the techniques in machine learning, such as artificial neural network, belief network, reinforcement learning, transfer learning, inductive learning, and method-based learning.
[0121] Exemplarily, the test case generation model may be any one of a neural network model, a logistic regression model, a linear regression model, a support vector machine (SVM), an Adaboost, an XGboost, and a Transformer-Encoder model.
[0122] Exemplarily, the neural network model can be any one of a recurrent neural network-based model, a convolutional neural network-based model, and a Transformer-encoder-based classification model.
[0123] Exemplarily, the test case generation model may be a deep hybrid model of a recurrent neural network-based model, a convolutional neural network-based model, and a Transformer-encoder-based classification model.
[0124] Exemplarily, the test case generation model can be any one of an attention-based deep model, a memory network-based deep model, and a deep learning-based short text classification model.
[0125] The short text classification model based on deep learning is a recurrent neural network (RNN) or a convolutional neural network (CNN) or a variant based on a recurrent neural network or a convolutional neural network.
[0126] Exemplarily, some simple domain adaptation transformation can be performed on the pre-trained model to obtain the first machine model.
[0127] Exemplarily, “simple domain adaptation” includes but is not limited to re-pre-training an already pre-trained model using large-scale unsupervised domain corpus, and / or compressing an already pre-trained model by model distillation.
[0128] Step S403: Obtain the test failure reason of the second test case, where the second test case is a test case in which the application test fails due to the lack of an object among the multiple first test cases; the test failure reason includes the object and the role of the object in the second test case.
[0129] It is understandable that although the test case generation model has been trained, the first test case generated by the test case generation model may not be very accurate, such as lacking some necessary objects. For example, the test case corresponding to creating a new order needs to include two parameters, product and user, otherwise the order cannot be created. If the test case corresponding to creating a new order does not include the two parameters of product and user (necessary objects), even if the application is tested, it cannot be successfully tested because there is a problem with the test case corresponding to creating a new order.
[0130] Based on this, in order to detect whether the first test case generated by the test case generation model lacks some necessary objects, the first test case can be used to test the application. If the first test case fails to test the application, there may be the following three situations.
[0131] Case 1: There is an error in the application itself, and there is no error in the first test case.
[0132] Case 2: There is no error in the application itself, but there is an error in the first test case.
[0133] Case 3: There is an error in the application itself and there is an error in the first test case.
[0134] The above three situations can be distinguished by the test failure reasons of the test cases that failed the test. There are many methods for obtaining the test failure reasons of the test cases. The embodiments of the present application provide but are not limited to the following three methods:
[0135] The first method is to check the error message and HTTP (HyperTextTransfer Protocol) status code returned by the test case that failed the test. This information can provide clues to the cause of the failure.
[0136] The second method is to check the log files of the application under test and look for exceptions, errors or warnings.
[0137] The third method is to use debugging tools to step through the code of the test case, observe the behavior of the program, and find out the exact location of the failure.
[0138] The method is used to determine the second test case among the test cases that failed because the test case has an error.
[0139] Exemplarily, the missing object in the second test case may be data. For example, the test case corresponding to creating a new order needs to include two parameters, product and user, otherwise the order cannot be created. In this case, "product" and "user" are data. The role of "product" and "user" in the second test case is a precondition.
[0140] Exemplarily, the object missing in the second test case may be call information for calling a downstream interface, for example, the second test case includes interface A, and interface A needs to call interface B, but the second test case does not contain call information for calling interface B. The call information in the second test case serves as a call condition.
[0141] Step S404: Based on the test failure reason of the second test case, obtain a first Prompt word.
[0142] The first prompt provides a clear optimization goal and specific improvement measures for the test case generation model, aiming to guide the test case generation model to improve the quality of test case generation through learning and adjustment.
[0143] The following example illustrates the first prompt word. Assume that the object included in the test failure reason of the second test case functions as a precondition.
[0144] {
Model optimization instructions
[0145] Objective: Improve the accuracy and coverage of test case generation.
[0146] Background: The current test case generation model has insufficient accuracy when generating test cases, resulting in test failures.
[0147] Task: Adjust your algorithm and learning strategy based on the following failure cases and improvement directions.
[0148] Failure case analysis:
[0149] - Test Case ID: TC-001
[0150] - Interface path: / api / users
[0151] - Method: POST
[0152] - Input parameters: {"username": "testuser", "password": "password123"}
[0153] - Expected result: Status code 201, response body containing user ID
[0154] - Actual result: Status code 500, internal server error
[0155] - Analysis: The test case failed to correctly simulate the user creation process and lacked necessary precondition checks
[0156] Improvement directions:
[0157] 1. Enhance the interface dependency analysis capability to ensure that all preconditions and postconditions are taken into account when generating test cases.
[0158] 2. Optimize the test data generation logic to ensure that the input parameters meet the interface requirements, including data type, format, and business rules.
[0159] 3. Improve the ability to generate test cases for error handling and exception processes to ensure that more exception scenarios can be covered.
[0160] 4. Strengthen the learning mechanism and adjust and optimize the test case generation strategy through feedback from failure cases.
[0161] Update measures:
[0162] - Retrain the test case generation model, using more labeled first test cases and second test cases as training data.
[0163] - Adjust the decision tree or neural network structure of the test case generation model to better capture the complex relationships between interfaces.
[0164] - Introduce more business logic rules to enhance the test case generation model's understanding and application of specific domain knowledge.
[0165] - Increase the self-assessment and self-correction capabilities of the test case generation model so that it can automatically adjust the generation strategy based on the test results.
[0166] Please regenerate the test cases after implementing the above adjustments and verify them to ensure the effectiveness of the improvement measures. The goal is to increase the accuracy of the test cases to more than 95% while reducing the test failure rate caused by test case problems.
[0167]
End command
[0168] Step S405: taking the first Prompt word and the first training set as input, taking the training annotated test cases of the first training set as training targets, and training the test case generation model.
[0169] Since the first prompt word provides a clear optimization goal and specific improvement measures for the test case generation model, it aims to guide the test case generation model to improve the generation quality of test cases through learning and adjustment.
[0170] The embodiment of the present application provides a test case generation model training method, which obtains a preset sample script, a first training set, and a training annotated test case corresponding to the first training set; the sample script and the first training set are input into the test case generation model, and a plurality of first test cases are obtained through the test case generation model; although the test case generation model has been trained, the first test case generated by the test case generation model may not be accurate, such as lacking some necessary objects. In order to detect whether the first test case generated by the test case generation model lacks some necessary objects, the first test case can be used to test the application. Determine the second test case in the first test case that failed the test because the test case has an error. Obtain the test failure reason of the second test case; based on the test failure reason of the second test case, obtain the first Prompt prompt word; the first Prompt prompt word provides a clear optimization goal and specific improvement measures for the test case generation model, aiming to guide the test case generation model to improve the generation quality of the test case through learning and adjustment. Therefore, the test case generation model obtained by retraining the first Prompt prompt word is more accurate, and the test case is obtained by the test case generation model, which improves efficiency without manual writing.
[0171] It is understandable that there are multiple ways to implement step S405. The embodiment of the present application provides but is not limited to the following method, which includes the following steps A1 to A6 during implementation.
[0172] Step A1: Obtain a first ratio of the number of the second test cases to the number of the first test cases.
[0173] The first ratio refers to the proportion of test cases with problems, i.e., missing objects, obtained by the test case generation model.
[0174] Step A2: input the first Prompt word and the first training set into the test case generation model, and obtain a plurality of third test cases through the test case generation model.
[0175] Step A3: Obtain a target number of fourth test cases among the plurality of third test cases; the fourth test case is a test case in which the application program test fails due to lack of an object.
[0176] Step A4: Determine a second ratio of the target number to the number of the third test cases.
[0177] The second ratio is the proportion of test cases with problems, i.e., missing objects, obtained by the test case generation model after retraining.
[0178] Step A5: If the second ratio is higher than or equal to the first ratio, a second Prompt word is obtained based on the first ratio, the second ratio, and the role played by the object missing from the fourth test case in the fourth test case.
[0179] It is understandable that if the second ratio is higher than the first ratio, it means that there is a problem with the first Prompt word and the improvement direction of the test case generation model is wrong, so the first Prompt word needs to be corrected to obtain the second Prompt word.
[0180] The following example illustrates the second Prompt word.
[0181] {
Model optimization instructions
[0182] Objective: Optimize the test case generation model to improve the accuracy of test cases.
[0183] Background: After the most recent test case generation model update, the accuracy of the test cases dropped from 85% to 75%, and the error rate increased, especially in the processing of the second test case.
[0184] Task: Please adjust your test case generation model according to the following instructions:
[0185] 1. Dataset review:
[0186] Re-evaluate the first training set to ensure that it contains diverse test scenarios to avoid overfitting the test case generation model to specific data.
[0187] 2. Model complexity adjustment:
[0188] Simplify the test case generation model structure or introduce regularization technology to reduce overfitting and improve the generalization ability of the test case generation model.
[0189] 3. Boundary condition processing:
[0190] Strengthen the test case generation model's ability to handle boundary conditions and outliers, especially when generating test data, to ensure that more abnormal scenarios can be covered.
[0191] 4. Business rule enhancement:
[0192] Introduce more business rules and logic to improve the test case generation model's understanding and application of specific domain knowledge.
[0193] 5. Self-assessment mechanism:
[0194] Enhance the self-assessment and self-correction capabilities of the test case generation model so that it can automatically adjust the generation strategy based on the test results.
[0195] 6. Feedback loop:
[0196] Establish an effective feedback loop mechanism so that the test case generation model can self-optimize based on the actual test results.
[0197] Please regenerate the test cases after implementing the above adjustments and verify them to ensure the effectiveness of the improvement measures. The goal is to increase the accuracy of the test cases to more than 90% and reduce the test failure rate caused by test case problems. We hope that your test case generation model update can bring more accurate and reliable test case generation capabilities.
[0198]
End command
[0199] Step A6: Take the second Prompt word and the first training set as input, take the training annotated test cases of the second training set as training targets, and train the test case generation model.
[0200] It can be understood that if the proportion of problematic test cases, i.e., test cases with missing objects, obtained by the test case generation model after being updated again by the second Prompt word still does not decrease, the second Prompt word is adjusted again until the accuracy of the test case generation model reaches the preset accuracy threshold.
[0201] In an optional implementation, the following steps B1 to B2 are also included.
[0202] Step B1: If the second ratio is lower than the first ratio, obtain a second training set and training annotated test cases corresponding to the second training set; the second training set includes definition information corresponding to multiple interfaces and dependency relationships between the multiple interfaces.
[0203] Exemplarily, the second training set is different from the first training set. The description of the second training set can refer to the first training set, which will not be repeated here.
[0204] If the second ratio is lower than the first ratio, it means that the improvement direction of the test case generation model is correct, and the first Prompt word can be used to continue training the test case generation model so that the accuracy of the test case generation model reaches the preset accuracy threshold.
[0205] Step B2: Take the first Prompt word and the second training set as input, take the training annotated test cases of the second training set as training targets, and train the test case generation model.
[0206] In an optional implementation, there are multiple implementations of step S401. The embodiment of the present application provides but is not limited to the following method, which includes the following steps: inputting the Swagger interface document into a pre-built interface information analysis model, and obtaining the first training set through the interface information analysis model.
[0207] Among them, the interface information analysis model is obtained by training with a sample Swagger interface document as input and a sample annotation training set as a training target. The sample annotation training set includes the sample Swagger interface document, including definition information corresponding to multiple interfaces and the dependency relationship between multiple interfaces.
[0208] The following example illustrates this, assuming that the Swagger interface document is as follows:
[0209] swagger: '2.0'
[0210] info:
[0211] title: E-commerce Platform API
[0212] description: Provides functions such as user management, product browsing and order processing
[0213] version: '1.0.0'
[0214] host: 'api.example.com'
[0215] basePath: /
[0216] Schemes:
[0217] https
[0218] paths:
[0219] / users:
[0220] get:
[0221] summary: Get a list of users
[0222] responses:
[0223] '200':
[0224] description: Successfully returned user list
[0225] / products:
[0226] get:
[0227] summary: Get a list of products
[0228] responses:
[0229] '200':
[0230] description: Successfully returned product list
[0231] post:
[0232] summary: Create a new product
[0233] responses:
[0234] '201':
[0235] description: Product created successfully
[0236] / orders:
[0237] post:
[0238] summary: Create a new order
[0239] responses:
[0240] '201':
[0241] description: Order created successfully
[0242] / orders / {orderId}:
[0243] get:
[0244] summary: Get order details by ID
[0245] responses:
[0246] '200':
[0247] description: Successfully returned order details
[0248] Then, the first training set obtained is as follows:
[0249] json
[0250] {
[0251] "Interface definition": {
[0252] " / users": {
[0253] "GET": {
[0254] "summary": "Get user list",
[0255] "responses": {
[0256] "200": "Successfully returned user list"}}},
[0257] " / products": {
[0258] "GET": {
[0259] "summary": "Get product list",
[0260] "responses": {
[0261] "200": "Successfully returned to product list"
[0262] }},
[0263] "POST": {
[0264] "summary": "Create a new product",
[0265] "responses": {
[0266] "201": "Product created successfully"
[0267] }}},
[0268] " / orders": {
[0269] "POST": {
[0270] "summary": "Create a new order",
[0271] "responses": {
[0272] "201": "Order created successfully"}}},
[0273] " / orders / {orderId}": {
[0274] "GET": {
[0275] "summary": "Get order details by ID",
[0276] "responses": {
[0277] "200": "Successfully returned order details"}}}},
[0278] "Hierarchical relationship between interfaces": {
[0279] " / orders": {
[0280] "dependencies": [" / users", " / products"]
[0281] },
[0282] " / orders / {orderId}": {
[0283] "dependencies": [" / orders"]}}}.
[0284] It is understandable that as the complexity of the application increases, the test cases obtained by the test case generation model may not be able to fully cover all interfaces of the application, resulting in insufficient test coverage. Based on this, the embodiment of the present application provides the following method, which includes the following steps B1 to B3 during implementation.
[0285] Step B1: Acquire the target interface of the application program that has not been tested.
[0286] The following describes a method for obtaining a target interface that has not been tested by an application.
[0287] The first method is to maintain a test case library, which includes test cases corresponding to multiple interfaces. The interface corresponding to the test case that failed the test application is the target interface that has not been tested.
[0288] The second method: Analyze the test coverage of the application code through the test coverage tool to determine which interfaces have been tested and which interfaces have not been tested; determine the untested interfaces as target interfaces.
[0289] The third method: deploy one or more monitoring agents to track the execution process of test cases, especially to detect those test cases that failed. The monitoring agent collects detailed information about the test cases that failed, including the reason for the failure, related interfaces, input parameters, and expected output. The monitoring agent identifies the interfaces that were not executed during the test process based on the detailed information of the test cases.
[0290] It is understandable that the target interface that is not tested may be caused by missing test cases or incomplete test paths.
[0291] Step B2: Based on the target interface, obtain a third Prompt word.
[0292] The following example illustrates the third Prompt word.
[0293] {
Model optimization instructions
[0294] Objective: Optimize the test case generation model to improve the test success rate of interfaces corresponding to failed test cases.
[0295] Background: In recent test execution, it was found that the test cases of the following interfaces failed, and a test case generation model was needed to learn the failure reasons and optimize the test cases.
[0296] List of failed interfaces and reasons for failure:
[0297] 1. Interface ID: TC-001
[0298] - Interface path: / api / users
[0299] - Failure reason: Lack of necessary user authentication information, resulting in status code 401.
[0300] 2. Interface ID: TC-002
[0301] - Interface path: / api / orders
[0302] - Failure reason: The request parameters do not meet the business rules, resulting in status code 400.
[0303] 3. Interface ID: TC-003
[0304] - Interface path: / api / products
[0305] - Failure reason: The dependent front-end interface was not executed correctly, resulting in inconsistent data and status code 500.
[0306] Task: For the above failed test cases, please adjust your algorithm and learning strategy to generate more accurate test cases.
[0307] Improvement directions:
[0308] 1. For the interface / api / users, please strengthen the logic of generating authentication information and ensure that each test case contains the correct authentication token.
[0309] 2. For the interface / api / orders, please optimize the parameter verification mechanism to ensure that the generated test data complies with business rules.
[0310] 3. For interfaces / api / products, please enhance interface dependency analysis to ensure that the front-end interface is correctly executed and generates necessary data.
[0311] Update measures:
[0312] - Retrain the test case generation model, using the annotated success and failure test cases as training data.
[0313] - Adjust the test case generation model parameters to enhance the ability to identify the cause of failure.
[0314] - Introduce more business rules and exception handling logic to enhance the adaptability and robustness of the test case generation model.
[0315] - Increase the self-assessment and self-correction capabilities of the test case generation model so that it can automatically adjust the generation strategy based on the test results.
[0316] Please regenerate the test cases after implementing the above adjustments and verify them to ensure the effectiveness of the improvement measures. The goal is to significantly reduce the proportion of failed test cases and increase the test success rate of the corresponding interface.
[0317]
End command
[0318] Step B3: taking the third Prompt word and the first training set as input, taking the training annotated test cases corresponding to the first training set as training targets, and training the test case generation model.
[0319] The third prompt provides a clear task and goal for the test case generation model, points out the specific interface that needs to be optimized, and gives the direction and measures for improvement. In this way, the test case generation model can be trained to identify and generate test cases for target interfaces that have not been executed, thereby improving the comprehensiveness and effectiveness of the test.
[0320] The above introduces a test case generation model training method provided by an embodiment of the present application. The following will introduce a device for executing the above test case generation model training method.
[0321] See also Figure 5 , Figure 5 A schematic diagram of the structure of a test case generation model training device provided in an embodiment of the present application. Figure 5 As shown, the test case generates a model training device, including:
[0322] The first acquisition module 501 is used to acquire a preset sample script, a first training set, and a training annotation test case corresponding to the first training set; the first training set includes definition information corresponding to a plurality of interfaces and dependency relationships between the plurality of interfaces;
[0323] A second acquisition module 502, configured to input the sample script and the first training set into a test case generation model, and acquire a plurality of first test cases through the test case generation model;
[0324] The test case generation model is obtained by taking the sample script, the definition information corresponding to the plurality of sample interfaces, and the dependency relationship between the plurality of sample interfaces as input, and taking the sample annotated test case as the training target;
[0325] A third acquisition module 503 is used to acquire a test failure reason of a second test case, where the second test case is a test case in which the application program test fails due to a lack of an object among the plurality of first test cases; the test failure reason includes the object and the role of the object in the second test case;
[0326] A fourth acquisition module 504 is used to acquire a first Prompt word based on the test failure reason of the second test case;
[0327] The first training module 505 is used to take the first Prompt word and the first training set as input, take the training annotated test cases of the first training set as training targets, and train the test case generation model.
[0328] In an optional implementation, the first training module includes:
[0329] A first acquiring unit, configured to acquire a first ratio of the number of the second test cases to the number of the first test cases;
[0330] A second acquisition unit, configured to input the first Prompt word and the first training set into the test case generation model, and acquire a plurality of third test cases through the test case generation model;
[0331] A third acquisition unit, configured to acquire a target number of fourth test cases from among the plurality of third test cases; the fourth test case being a test case in which the application program test fails due to a lack of an object;
[0332] a first determining unit, configured to determine a second ratio of the target number to the number of the third test cases;
[0333] A fourth acquisition unit is configured to acquire a second Prompt word based on the first ratio, the second ratio, and the role of the object missing from the fourth test case in the fourth test case if the second ratio is higher than or equal to the first ratio;
[0334] The first training unit is used to take the second Prompt word and the first training set as input, take the training annotated test cases of the second training set as training targets, and train the test case generation model.
[0335] In an optional implementation, the method further includes:
[0336] A fifth acquisition module, configured to acquire a second training set and a training annotation test case corresponding to the second training set if the second ratio is lower than the first ratio; the second training set includes definition information corresponding to a plurality of interfaces and dependency relationships between the plurality of interfaces;
[0337] The second training module is used to take the first Prompt word and the second training set as input, take the training annotated test cases of the second training set as training targets, and train the test case generation model.
[0338] In an optional implementation, the first acquisition module includes:
[0339] A fifth acquisition unit, used to input the Swagger interface document into a pre-built interface information analysis model, and obtain the first training set through the interface information analysis model;
[0340] Among them, the interface information analysis model is obtained by training with a sample Swagger interface document as input and a sample annotation training set as a training target. The sample annotation training set includes the sample Swagger interface document, including definition information corresponding to multiple interfaces and the dependency relationship between multiple interfaces.
[0341] In an optional implementation, the method further includes:
[0342] A sixth acquisition module, used to acquire a target interface of the application that has not been tested;
[0343] A seventh acquisition module, configured to acquire a third Prompt word based on the target interface;
[0344] The third training module is used to take the third Prompt word and the first training set as input, take the training annotated test cases corresponding to the first training set as training targets, and train the test case generation model.
[0345] The present application also provides an electronic device in an embodiment. Figure 6 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0346] like Figure 6 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0347] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0348] An embodiment of the present application also provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any test case generation model training method provided in the embodiment of the present application.
[0349] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any test case generation model training method provided in the embodiment of the present application.
[0350] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0351] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0352] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0353] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A test case generation model training method, characterized in that: include: Obtaining a preset sample script, a first training set, and training annotated test cases corresponding to the first training set; The first training set includes definition information corresponding to a plurality of interfaces respectively and dependency relationships between the plurality of interfaces; Inputting the sample script and the first training set into a test case generation model, and obtaining a plurality of first test cases through the test case generation model; The test case generation model is obtained by taking the sample script, the definition information corresponding to the plurality of sample interfaces, and the dependency relationship between the plurality of sample interfaces as input, and taking the sample annotated test case as the training target; Obtaining a test failure reason of a second test case, where the second test case is a test case in which the application program test fails due to a lack of an object among the plurality of first test cases; the test failure reason includes the object and the role of the object in the second test case; Based on the test failure reason of the second test case, obtain a first Prompt word; The first Prompt word and the first training set are taken as input, and the training annotated test cases of the first training set are taken as training targets to train the test case generation model.
2. The test case generation model training method according to claim 1, characterized in that: The step of taking the first Prompt word and the first training set as input, taking the training annotated test cases of the first training set as training targets, and training the test case generation model comprises: Obtaining a first ratio of the number of the second test cases to the number of the first test cases; Inputting the first Prompt word and the first training set into the test case generation model, and obtaining a plurality of third test cases through the test case generation model; Obtaining a target number of fourth test cases among the plurality of third test cases; the fourth test case is a test case in which the application program test fails due to lack of an object; determining a second ratio of the target number to the number of the third test cases; If the second ratio is higher than or equal to the first ratio, based on the first ratio, the second ratio, and the role of the object missing from the fourth test case in the fourth test case, obtaining a second Prompt word; The second Prompt word and the first training set are taken as input, and the training annotated test cases of the second training set are taken as training targets to train the test case generation model.
3. The test case generation model training method according to claim 2, characterized in that: Also includes: If the second ratio is lower than the first ratio, obtaining a second training set and training annotated test cases corresponding to the second training set; The second training set includes definition information corresponding to a plurality of interfaces respectively and dependency relationships between the plurality of interfaces; The first Prompt word and the second training set are taken as input, and the training annotated test cases of the second training set are taken as training targets to train the test case generation model.
4. The test case generation model training method according to any one of claims 1 to 3, characterized in that: Acquiring the first training set includes: Inputting the Swagger interface document into a pre-built interface information analysis model, and obtaining the first training set through the interface information analysis model; Among them, the interface information analysis model is obtained by training with a sample Swagger interface document as input and a sample annotation training set as a training target. The sample annotation training set includes the sample Swagger interface document, including definition information corresponding to multiple interfaces and the dependency relationship between multiple interfaces.
5. The test case generation model training method according to claim 1, characterized in that: Also includes: Obtaining a target interface of the application that is not tested; Based on the target interface, obtain a third Prompt prompt word; The third Prompt word and the first training set are taken as input, and the training annotated test cases corresponding to the first training set are taken as training targets to train the test case generation model.
6. A test case generation model training device, characterized in that: include: A first acquisition module, used to acquire a preset sample script, a first training set, and a training annotated test case corresponding to the first training set; The first training set includes definition information corresponding to a plurality of interfaces respectively and dependency relationships between the plurality of interfaces; A second acquisition module, used for inputting the sample script and the first training set into a test case generation model, and acquiring a plurality of first test cases through the test case generation model; The test case generation model is obtained by taking the sample script, the definition information corresponding to the plurality of sample interfaces, and the dependency relationship between the plurality of sample interfaces as input, and taking the sample annotated test case as the training target; A third acquisition module is used to obtain the test failure reason of a second test case, where the second test case is a test case in which the application test fails due to a lack of an object among the plurality of first test cases; the test failure reason includes the object and the role of the object in the second test case; A fourth acquisition module, configured to acquire a first Prompt word based on the test failure reason of the second test case; The first training module is used to take the first Prompt word and the first training set as input, take the training annotated test cases of the first training set as training targets, and train the test case generation model.
7. The test case generation model training device according to claim 6, characterized in that: The first training module includes: A first acquiring unit, configured to acquire a first ratio of the number of the second test cases to the number of the first test cases; A second acquisition unit, configured to input the first Prompt word and the first training set into the test case generation model, and acquire a plurality of third test cases through the test case generation model; A third acquisition unit, configured to acquire a target number of fourth test cases from among the plurality of third test cases; the fourth test case being a test case in which the application program test fails due to a lack of an object; a first determining unit, configured to determine a second ratio of the target number to the number of the third test cases; A fourth acquisition unit is configured to acquire a second Prompt word based on the first ratio, the second ratio, and the role of the object missing from the fourth test case in the fourth test case if the second ratio is higher than or equal to the first ratio; The first training unit is used to take the second Prompt word and the first training set as input, take the training annotated test cases of the second training set as training targets, and train the test case generation model.
8. A computer program product, characterized in that It includes computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the test case generation model training method as described in any one of claims 1 to 5.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the test case generation model training method as described in any one of claims 1 to 5.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the test case generation model training method as described in any one of claims 1 to 5.