Test case generation method, device, equipment and medium

By performing verification and mask rule screening on the test case generation instructions, and combining the artificial intelligence model to generate test cases, the problem of lack of generalization ability in use case generation in the existing technology is solved, the usability and acceptance rate of use cases are improved, and more efficiency is achieved test case generation.

CN118503141BActive Publication Date: 2024-10-22LESHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410972016.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-10-22
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

Existing test case generation methods lack generalization capabilities, resulting in use case editing taking up a lot of workload, and the conventional rules are patterned and cannot effectively handle complex scenarios.

Method used

By verifying the test case generation instructions, combined with the requirements specification description document, system implementation logic description document and solution description document, the pre-trained test case generation model is used to generate an alternative use case set, and the target test cases are screened out based on the mask rules. Combined with artificial intelligence means to enhance the generalization ability of use case generation.

Benefits of technology

It improves the usability and acceptance rate of test cases, improves the efficiency and accuracy of the use case generation process, and enhances the ability to handle complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503141B_ABST
    Figure CN118503141B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of testing technology, and provides a test case generation method, device, equipment and medium, which can first verify the test case generation instruction to improve the safety of the test; integrate the multi-dimensional data of the requirement specification description document, the system implementation logic description document and the solution description document as the data to be processed, and use the large language model to generate an alternative case set to ensure that the alternative case set that meets the requirements can be initially generated; based on the mask rule, the alternative case set is screened to obtain at least one target test case, thereby further improving the availability of the generated test case; and combine artificial intelligence means and mask rules to automatically generate test cases, thereby enhancing the generalization ability of the case generation process and improving the acceptance rate of the generated test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of testing technology, and in particular to a test case generation method, device, equipment and medium. Background Art

[0002] In the prior art, when test engineers are writing test cases, case editing takes up a lot of work.

[0003] Moreover, when writing test cases, conventional use case generation rules such as directed graphs, boundary values, equivalence classes, orthogonal graphs, etc. are relatively stereotyped and lack generalization capabilities. Summary of the invention

[0004] In view of the above, it is necessary to provide a test case generation method, apparatus, device and medium, aiming to solve the problem that the test case generation method lacks generalization.

[0005] A test case generation method, the test case generation method comprising:

[0006] In response to the test case generation instruction, verifying the test case generation instruction;

[0007] When the test case generation instruction passes the verification, the requirement specification description document, the system implementation logic description document and the solution description document are obtained as the data to be processed according to the test case generation instruction;

[0008] Inputting the data to be processed into a pre-trained test case generation model, and constructing a set of alternative use cases according to the output data of the test case generation model;

[0009] A preconfigured mask rule is obtained, and the test cases in the candidate test case set are screened using the mask rule to obtain at least one target test case.

[0010] According to a preferred embodiment of the present invention, the verifying the test case generation instruction includes:

[0011] Parsing the test case generation instruction to obtain the trigger of the test case generation instruction and the login parameters of the trigger;

[0012] When the login parameters are an account number and a password, detect whether there is a feedback token; when a first token with feedback is detected, add the first token to the request header to obtain a verification token; send the verification token to a designated platform for verification; or

[0013] When the login parameter is a device parameter, determine the requesting device according to the device parameter; detect whether the requesting device is in the pre-configured device list; when the requesting device is in the device list, detect whether there is a feedback token; when a second token with feedback is detected, obtain the time when the test case generation instruction is triggered by the requesting device as the trigger time; generate a random string; concatenate the second token, the device parameter, the trigger time and the random string to obtain a field to be checked; send the field to be checked to the designated platform for verification; wherein the device list is used to store all devices with the authority to generate test cases; or

[0014] When the login parameter is an unknown interface parameter, the unknown interface is determined according to the unknown interface parameter; the access key identifier and the initial key assigned to the unknown interface are obtained; the initial key is encrypted to obtain a target key; and the access key identifier and the target key are sent to the designated platform for verification.

[0015] According to a preferred embodiment of the present invention, encrypting the initial key to obtain the target key includes:

[0016] In the T box corresponding to the initial key, the initial key is split to obtain a preset number of key segments;

[0017] For each key segment, a pre-constructed state transformation matrix is ​​obtained; wherein the state transformation matrix is ​​used to scramble the row data and column data of each key segment;

[0018] Calculate the product of each key segment and the state transformation matrix to obtain each key segment after scrambling;

[0019] Using the initial key to encrypt each of the scrambled key segments to obtain each key ciphertext;

[0020] The key ciphertext is processed by using the T box, and output data of the T box is obtained as the target key.

[0021] According to a preferred embodiment of the present invention, before inputting the data to be processed into a pre-trained test case generation model, the method further includes:

[0022] Acquire historical test cases, and construct training samples based on the historical test cases;

[0023] Using the training samples to train a large language model;

[0024] In each round of training, obtain the value of the loss function of that round;

[0025] When the value of the loss function reaches convergence, the training is stopped to obtain the test case generation model.

[0026] According to a preferred embodiment of the present invention, constructing a training sample based on the historical test case includes:

[0027] Acquire use cases whose usage times are less than or equal to a preset number of times from the historical test cases to construct a first use case set;

[0028] Get the current timestamp, and trace back a preset time from the current timestamp to get the target timestamp;

[0029] Determine a time interval consisting of the current timestamp and the target timestamp as a target time period;

[0030] Acquire the use cases whose usage times are greater than the preset times and abnormalities are found within the target time period from the historical test cases to construct a second use case set;

[0031] Acquire the use cases whose usage times are greater than the preset times and no abnormalities are found within the target time period from the historical test cases to construct a third use case set;

[0032] Obtaining a first prediction model trained based on the use case change information, and using the first prediction model to predict each first use case in the first use case set to obtain an anomaly detection accuracy rate of each predicted first use case;

[0033] Arrange each first case in descending order according to the anomaly detection accuracy of each first case to obtain a first case sequence;

[0034] Get the configured accuracy threshold;

[0035] The first use case sequence is split based on the accuracy threshold to obtain a first subsequence and a second subsequence; wherein the anomaly detection accuracy of each use case in the first subsequence is greater than the anomaly detection accuracy of each use case in the second subsequence;

[0036] Obtaining a second prediction model trained based on the use case usage information, and using the second prediction model to predict each second use case in the second use case set to obtain an anomaly detection accuracy rate of each predicted second use case;

[0037] Arrange each second use case in descending order of anomaly detection accuracy of each second use case to obtain a second use case sequence;

[0038] The second use case sequence is split based on the accuracy threshold to obtain a third subsequence and a fourth subsequence; wherein the anomaly detection accuracy of each use case in the third subsequence is greater than the anomaly detection accuracy of each use case in the fourth subsequence;

[0039] Obtaining the total number of times each third use case in the third use case set is used, and the number of times an anomaly is detected during use;

[0040] Calculate the quotient of the number of times an anomaly is detected corresponding to each third use case and the total number of times used to obtain a target indicator value corresponding to each third use case;

[0041] Arrange each third use case in descending order according to the target indicator value corresponding to each third use case to obtain a third use case sequence;

[0042] sequentially concatenating the third subsequence, the first subsequence, the second subsequence, the fourth subsequence and the third example sequence to obtain a target sequence;

[0043] A preset proportion of use cases are extracted from the target sequence in order from front to back to construct the training samples.

[0044] According to a preferred embodiment of the present invention, before obtaining the pre-configured mask rule, the method further includes:

[0045] Determine the test domain according to the test case generation instruction, and determine the role of the triggerer in the test process;

[0046] Generate test constraints according to the test domain and the role;

[0047] The mask rule is generated according to the test restriction condition.

[0048] According to a preferred embodiment of the present invention, after obtaining at least one target test case, the method further includes:

[0049] Feedback the at least one target test case to the triggerer;

[0050] Detecting a selection operation, a modification operation, and a new addition operation of the at least one target test case by the triggerer;

[0051] Receiving optimized test cases generated according to the selection operation and the modification operation, and receiving newly added test cases generated according to the newly added operation;

[0052] Combining the optimized test case and the newly added test case to obtain a test case to be used;

[0053] Testing is performed based on the test case to be used, and the test case generation model is optimized and trained using the test case to be used.

[0054] A test case generating device, the test case generating device comprising:

[0055] A verification unit, configured to verify the test case generation instruction in response to the test case generation instruction;

[0056] An acquisition unit, configured to acquire a requirement specification description document, a system implementation logic description document and a solution description document as data to be processed according to the test case generation instruction when the test case generation instruction passes verification;

[0057] A construction unit, used for inputting the data to be processed into a pre-trained test case generation model, and constructing a set of alternative use cases according to the output data of the test case generation model;

[0058] The screening unit is used to obtain a pre-configured mask rule and use the mask rule to screen the test cases in the candidate test case set to obtain at least one target test case.

[0059] A computer device, comprising:

[0060] a memory storing at least one instruction; and

[0061] A processor executes instructions stored in the memory to implement the test case generation method.

[0062] A computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the test case generation method.

[0063] It can be seen from the above technical solutions that the present invention can first verify the test case generation instructions to improve the safety of the test; integrate the multi-dimensional data of the requirement specification description document, the system implementation logic description document and the solution description document as the data to be processed, and use the large language model to generate a set of alternative use cases to ensure that a set of alternative use cases that meets the requirements can be initially generated; based on the mask rule, the alternative use case set is screened to obtain at least one target test case, further improving the availability of the generated test cases; combining artificial intelligence means and mask rules to automatically generate test cases, enhancing the generalization ability of the use case generation process, and improving the acceptance rate of the generated test cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 It is a flow chart of a preferred embodiment of the test case generation method of the present invention.

[0065] Figure 2 It is a functional module diagram of a preferred embodiment of the test case generation device of the present invention.

[0066] Figure 3 It is a structural schematic diagram of a computer device of a preferred embodiment of the test case generation method of the present invention. DETAILED DESCRIPTION

[0067] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0068] like Figure 1 FIG. 1 is a flow chart of a preferred embodiment of the test case generation method of the present invention. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.

[0069] The test case generation method is applied to one or more computer devices, which are devices that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and whose hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0070] The computer device may be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.

[0071] The computer device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.

[0072] The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0073] Among them, Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0074] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0075] The network where the computer device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0076] S10, in response to the test case generation instruction, verifying the test case generation instruction.

[0077] In this embodiment, the test case generation instruction may be triggered by a tester or other relevant staff.

[0078] In this embodiment, the verifying the test case generation instruction includes:

[0079] Parsing the test case generation instruction to obtain the trigger of the test case generation instruction and the login parameters of the trigger;

[0080] When the login parameters are an account number and a password, detect whether there is a feedback token; when a first token with feedback is detected, add the first token to the request header to obtain a verification token; send the verification token to a designated platform for verification; or

[0081] When the login parameter is a device parameter, determine the requesting device according to the device parameter; detect whether the requesting device is in the pre-configured device list; when the requesting device is in the device list, detect whether there is a feedback token; when a second token with feedback is detected, obtain the time when the test case generation instruction is triggered by the requesting device as the trigger time; generate a random string; concatenate the second token, the device parameter, the trigger time and the random string to obtain a field to be checked; send the field to be checked to the designated platform for verification; wherein the device list is used to store all devices with the authority to generate test cases; or

[0082] When the login parameter is an unknown interface parameter, the unknown interface is determined according to the unknown interface parameter; the access key identifier and the initial key assigned to the unknown interface are obtained; the initial key is encrypted to obtain a target key; and the access key identifier and the target key are sent to the designated platform for verification.

[0083] The account may include a user login account, an enterprise identification code, etc.

[0084] Wherein, the designated platform has a verification function.

[0085] The device parameters may include a device identification code and the like.

[0086] Through the above embodiments, the test case generation instruction can be specifically verified according to different login parameter types to improve the accuracy of the verification.

[0087] In this embodiment, encrypting the initial key to obtain the target key includes:

[0088] In the T box corresponding to the initial key, split the initial key to obtain a preset number of key segments;

[0089] For each key segment, a pre-constructed state transformation matrix is ​​obtained; wherein the state transformation matrix is ​​used to scramble the row data and column data of each key segment;

[0090] Calculate the product of each key segment and the state transformation matrix to obtain each key segment after scrambling;

[0091] Using the initial key to encrypt each of the scrambled key segments to obtain each key ciphertext;

[0092] The key ciphertext is processed by using the T box, and output data of the T box is obtained as the target key.

[0093] The preset number can be configured according to actual needs, such as 10.

[0094] In the above embodiment, unlike the traditional encryption scheme that can only obfuscate text rows, the privacy after encryption is still low. This case is optimized on the basis of the traditional encryption scheme, and the row information and column information of the encrypted data are scrambled respectively, and then encrypted with the key, which further improves the security of the data and can effectively avoid data leakage.

[0095] S11, when the test case generation instruction passes the verification, the requirement specification description document, the system implementation logic description document and the solution description document are obtained as the data to be processed according to the test case generation instruction.

[0096] In this embodiment, the use case management platform can be determined according to the test case generation instruction, and the requirement specification description document, the system implementation logic description document and the solution description document are collected as the data to be processed through the unified use case management platform.

[0097] The use case management platform can provide test engineers and other relevant personnel with functions such as use case creation, editing, modification, viewing and storage, and is the main interactive interface for test engineers.

[0098] The requirement specification description document may be uploaded to the use case management platform by a product manager.

[0099] For example, the requirement specifications may include, but are not limited to, one or a combination of the following:

[0100] "The merchant clicks 'Place Order' and after the order is successfully placed, the system directly presents the payment code. There is an irregular handling fee for each order, and the handling fee rules are as follows:

[0101] Rule 1: When the merchant's order transaction amount is less than 10 yuan, the handling fee is 0;

[0102] Rule 2: When the merchant's daily transaction amount exceeds 1 million yuan, the handling fee is reduced to 0.2 per 10,000 yuan;

[0103] Rule 3:…”.

[0104] The system implementation logic description document may be uploaded to the use case management platform by developers and / or architects.

[0105] For example, the system implementation logic description document may include, but is not limited to, one or a combination of the following:

[0106] "The order generated by the transaction module is stored in the order_item_list database table, and the order record is appended to the memory linked list order_list_success, which includes the order number order_id, the transaction amount order_trade_amount, and the merchant ID shop_owner_id;

[0107] When the settlement system starts, it reads the merchant's rates from the database. The rates include two tables: a general rate table general_rate_list and a merchant customized rate table special_rate_list. The rules of the merchant customized rate table have a higher priority than the rules of the general rate table. The two rate tables are combined into rate settlement rules and stored in the rule engine;

[0108] The settlement module periodically obtains up to 100 orders from the memory list (every 5 seconds) and calculates the handling fee according to the merchant's current rate rules. The handling fee calculation is completed in the rule engine. After the calculation is completed, it is stored in the order_item_settlement database table, the settlement information is saved to the order_list_settlement memory list, and the settled orders are deleted from the order_list_success queue..."

[0109] The solution description document may also be uploaded to the use case management platform by developers and / or architects.

[0110] S12, inputting the data to be processed into a pre-trained test case generation model, and constructing a set of alternative use cases according to the output data of the test case generation model.

[0111] In this embodiment, the test case generation model may be a large language model.

[0112] In this embodiment, before inputting the data to be processed into a pre-trained test case generation model, the method further includes:

[0113] Obtaining historical test cases, and constructing training samples based on the historical test cases;

[0114] Using the training samples to train a large language model;

[0115] In each round of training, obtain the value of the loss function of that round;

[0116] When the value of the loss function reaches convergence, the training is stopped to obtain the test case generation model.

[0117] It is understandable that due to the different professionalism of testers and other issues, the quality of historical test cases will vary. Some test cases may not be of reference value and usability at all. Therefore, if a large number of use cases with low usability are used to train the model, the usability of the use cases output by the model will also not be strong. Therefore, when constructing training samples, it is necessary to first process and screen the historical test cases accordingly, rather than directly using all use cases as training samples as in traditional solutions, which will affect the quality of the trained model.

[0118] Specifically, constructing a training sample based on the historical test case includes:

[0119] Acquire use cases whose usage times are less than or equal to a preset number of times from the historical test cases to construct a first use case set;

[0120] Get the current timestamp, and trace back a preset time from the current timestamp to get the target timestamp;

[0121] Determine a time interval consisting of the current timestamp and the target timestamp as a target time period;

[0122] Acquire the use cases whose usage times are greater than the preset times and abnormalities are found within the target time period from the historical test cases to construct a second use case set;

[0123] Acquire the use cases whose usage times are greater than the preset times and no abnormalities are found within the target time period from the historical test cases to construct a third use case set;

[0124] Obtaining a first prediction model trained based on the use case change information, and using the first prediction model to predict each first use case in the first use case set to obtain an anomaly detection accuracy rate of each predicted first use case;

[0125] Arrange each first case in descending order according to the anomaly detection accuracy of each first case to obtain a first case sequence;

[0126] Get the configured accuracy threshold;

[0127] The first use case sequence is split based on the accuracy threshold to obtain a first subsequence and a second subsequence; wherein the anomaly detection accuracy of each use case in the first subsequence is greater than the anomaly detection accuracy of each use case in the second subsequence;

[0128] Obtaining a second prediction model trained based on the use case usage information, and using the second prediction model to predict each second use case in the second use case set to obtain an anomaly detection accuracy rate of each predicted second use case;

[0129] Arrange each second use case in descending order of anomaly detection accuracy of each second use case to obtain a second use case sequence;

[0130] The second use case sequence is split based on the accuracy threshold to obtain a third subsequence and a fourth subsequence; wherein the anomaly detection accuracy of each use case in the third subsequence is greater than the anomaly detection accuracy of each use case in the fourth subsequence;

[0131] Obtaining the total number of times each third use case in the third use case set is used, and the number of times an anomaly is detected during use;

[0132] Calculate the quotient of the number of times an anomaly is detected corresponding to each third use case and the total number of times used to obtain a target indicator value corresponding to each third use case;

[0133] Arrange each third use case in descending order according to the target indicator value corresponding to each third use case to obtain a third use case sequence;

[0134] sequentially concatenating the third subsequence, the first subsequence, the second subsequence, the fourth subsequence and the third example sequence to obtain a target sequence;

[0135] A preset proportion of use cases are extracted from the target sequence in order from front to back to construct the training samples.

[0136] The preset number of times can be configured according to the actual test scenario, such as 50.

[0137] The preset duration may also be configured according to actual test scenarios, such as 30 days.

[0138] The first prediction model and the second prediction model can be models such as neural networks with prediction functions. The first prediction model can use whether the use case has changed, the change time, etc. as input data, and use the anomaly detection accuracy as output data; the second prediction model can use various execution data related to the execution process (such as execution time, number of uses, error rate, etc.) as input data, and use the anomaly detection accuracy as output data.

[0139] Among them, when using the anomaly detection accuracy output by the model to arrange each use case, if there are two use cases with the same anomaly detection accuracy, the average test duration of the two use cases each time is calculated, and the use case with the smaller average duration is placed in front (the smaller the average duration, the higher the efficiency of each test). If the average duration is also the same, it means that the test performance of the two use cases is similar, and any one of the use cases can be placed in front.

[0140] The accuracy threshold may be 50%, etc., to ensure that each sequence is split reasonably.

[0141] Among them, the third subsequence is a use case sequence with a higher anomaly detection accuracy output after the model is trained with sufficient historical execution information. Therefore, the availability and accuracy of each use case in the third subsequence are higher, so the third subsequence is arranged in front of the final target sequence; based on a similar principle, the first subsequence, the second subsequence, the fourth subsequence and the third use case sequence are arranged in sequence, and the use cases that are arranged in the front in the target sequence have higher availability and accuracy.

[0142] Furthermore, the preset ratio is configured, such as 70%. The first 70% of the use cases are extracted from the target sequence in order from the front to the back to construct the training sample, which can not only ensure the sufficient amount of the training sample data, but also ensure the availability and accuracy of the training sample, thereby improving the quality of the test case generation model trained based on the training sample, so that the acceptance rate and availability of the test cases output by the test case generation model are higher.

[0143] The test case generation model may also support text-to-text interface access.

[0144] Through the above embodiments, before model training, use cases with stronger usability and higher accuracy can be screened out from historical test cases based on multi-dimensional factors and artificial intelligence means to construct training samples, so as to improve the accuracy of the trained model.

[0145] S13, obtaining a pre-configured mask rule, and using the mask rule to screen the test cases in the candidate test case set to obtain at least one target test case.

[0146] In this embodiment, before obtaining the pre-configured mask rule, the method further includes:

[0147] Determine the test domain according to the test case generation instruction, and determine the role of the triggerer in the test process;

[0148] Generate test constraints according to the test domain and the role;

[0149] The mask rule is generated according to the test restriction condition.

[0150] For example: the mask rules may include role restrictions on senior test engineers, as well as output format restrictions such as "the generated test cases need to include five aspects: test number, test name, prerequisites, test steps and expected results, and be presented in a table format" as restrictions on various aspects of the test field to ensure that the output test cases are easier to use.

[0151] By configuring the mask rules, the large model roles and preset rule management modules in the vertical field of use case generation are limited for test engineers, and the test cases output by the test case generation model can be further screened based on various restrictions to improve the applicability and acceptance rate of the final test cases.

[0152] The acceptance rate refers to the probability that the generated test case can be used directly.

[0153] In this embodiment, after obtaining at least one target test case, the method further includes:

[0154] Feedback the at least one target test case to the triggerer;

[0155] Detecting a selection operation, a modification operation, and a new addition operation of the at least one target test case by the triggerer;

[0156] Receiving optimized test cases generated according to the selection operation and the modification operation, and receiving newly added test cases generated according to the newly added operation;

[0157] Combining the optimized test case and the newly added test case to obtain a test case to be used;

[0158] Testing is performed based on the test case to be used, and the test case generation model is optimized and trained using the test case to be used.

[0159] Through the above embodiments, at least one generated target test case is first modified and selected based on actual needs to achieve re-screening and optimization of at least one generated target test case, thereby further improving the test accuracy and availability of the generated test case.

[0160] At the same time, testing and other related personnel can add test cases according to actual needs to achieve optimization training of the test case generation model. For example: after screening based on the mask rule, the test case generation model finally outputs 20 target test cases. After screening and modification by the triggerer, 15 available target test cases and 5 unavailable target test cases are finally retained. In addition, the triggerer has added an additional 20 available target test cases. The test case generation model can be optimized and trained together with the 15 retained available target test cases and the 20 newly added available target test cases, so as to continuously feed back the test case generation model according to each generated test case, ensure that the test case generation model is continuously optimized, and gradually increase the acceptance rate of the test cases output by the test case generation model.

[0161] It can be seen from the above technical solutions that the present invention can first verify the test case generation instructions to improve the safety of the test; integrate the multi-dimensional data of the requirement specification description document, the system implementation logic description document and the solution description document as the data to be processed, and use the large language model to generate a set of alternative use cases to ensure that a set of alternative use cases that meets the requirements can be initially generated; based on the mask rule, the alternative use case set is screened to obtain at least one target test case, further improving the availability of the generated test cases; combining artificial intelligence means and mask rules to automatically generate test cases, enhancing the generalization ability of the use case generation process, and improving the acceptance rate of the generated test cases.

[0162] like Figure 2 As shown, it is a functional module diagram of a preferred embodiment of the test case generation device of the present invention. The test case generation device 11 includes a verification unit 110, an acquisition unit 111, a construction unit 112, and a screening unit 113. The module / unit referred to in the present invention refers to a series of computer program segments that can be executed by a processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0163] Wherein, the verification unit 110 is used to verify the test case generation instruction in response to the test case generation instruction;

[0164] The acquisition unit 111 is used to acquire a requirement specification description document, a system implementation logic description document and a solution description document as data to be processed according to the test case generation instruction when the test case generation instruction passes the verification;

[0165] The construction unit 112 is used to input the data to be processed into a pre-trained test case generation model, and construct an alternative case set according to the output data of the test case generation model;

[0166] The screening unit 113 is used to obtain a pre-configured mask rule, and use the mask rule to screen the test cases in the candidate test case set to obtain at least one target test case.

[0167] It can be seen from the above technical solutions that the present invention can first verify the test case generation instructions to improve the safety of the test; integrate the multi-dimensional data of the requirement specification description document, the system implementation logic description document and the solution description document as the data to be processed, and use the large language model to generate a set of alternative use cases to ensure that a set of alternative use cases that meets the requirements can be initially generated; based on the mask rule, the alternative use case set is screened to obtain at least one target test case, further improving the availability of the generated test cases; combining artificial intelligence means and mask rules to automatically generate test cases, enhancing the generalization ability of the use case generation process, and improving the acceptance rate of the generated test cases.

[0168] like Figure 3 , which is a schematic diagram of the structure of a computer device of a preferred embodiment of the test case generation method of the present invention.

[0169] The computer device 1 may include a memory 12 , a processor 13 , and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13 , such as a test case generation program.

[0170] Those skilled in the art will appreciate that the schematic diagram is merely an example of the computer device 1 and does not constitute a limitation on the computer device 1. The computer device 1 may be a bus-type structure or a star-type structure. The computer device 1 may also include more or less other hardware or software than shown in the diagram, or a different arrangement of components. For example, the computer device 1 may also include input and output devices, network access devices, etc.

[0171] It should be noted that the computer device 1 is only an example, and other existing or future electronic products that are suitable for the present invention should also be included in the protection scope of the present invention and included here by reference.

[0172] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the computer device 1, such as a mobile hard disk of the computer device 1. In other embodiments, the memory 12 can also be an external storage device of the computer device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 1. Further, the memory 12 can also include both an internal storage unit of the computer device 1 and an external storage device. The memory 12 can not only be used to store application software and various types of data installed in the computer device 1, such as the code of the test case generation program, etc., but also can be used to temporarily store data that has been output or is to be output.

[0173] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the computer device 1, and uses various interfaces and lines to connect various components of the entire computer device 1, and executes various functions and processes data of the computer device 1 by running or executing programs or modules stored in the memory 12 (for example, executing a test case generation program, etc.), and calling data stored in the memory 12.

[0174] The processor 13 executes the operating system of the computer device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned test case generation method embodiments, for example Figure 1 Steps shown.

[0175] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the computer device 1. For example, the computer program may be divided into a verification unit 110, an acquisition unit 111, a construction unit 112, and a screening unit 113.

[0176] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, and includes a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of the test case generation method described in each embodiment of the present invention.

[0177] If the module / unit integrated in the computer device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware devices through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of each of the above-mentioned method embodiments can be implemented.

[0178] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, etc.

[0179] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0180] The blockchain referred to in this invention is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.

[0181] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The bus is represented by only one straight line, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.

[0182] Although not shown, the computer device 1 may also include a power source (such as a battery) for supplying power to various components. Preferably, the power source may be logically connected to the at least one processor 13 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, and power status indicators. The computer device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0183] Furthermore, the computer device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the computer device 1 and other computer devices.

[0184] Optionally, the computer device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the computer device 1 and to display a visual user interface.

[0185] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0186] Figure 3 Only the computer device 1 having components 12-13 is shown, and it can be understood by those skilled in the art that Figure 3The structure shown does not constitute a limitation on the computer device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0187] Combination Figure 1 , the memory 12 in the computer device 1 stores a plurality of instructions to implement a test case generation method, and the processor 13 can execute the plurality of instructions to implement:

[0188] In response to the test case generation instruction, verifying the test case generation instruction;

[0189] When the test case generation instruction passes the verification, the requirement specification description document, the system implementation logic description document and the solution description document are obtained as the data to be processed according to the test case generation instruction;

[0190] Inputting the data to be processed into a pre-trained test case generation model, and constructing a set of alternative use cases according to the output data of the test case generation model;

[0191] A preconfigured mask rule is obtained, and the test cases in the candidate test case set are screened using the mask rule to obtain at least one target test case.

[0192] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.

[0193] It should be noted that the data involved in this case were all obtained legally.

[0194] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

[0195] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

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

[0197] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0198] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0199] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0200] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the present invention can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

[0201] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A test case generation method, characterized in that: The test case generation method comprises: In response to a test case generation instruction, the test case generation instruction is verified, including: parsing the test case generation instruction to obtain the trigger of the test case generation instruction and the login parameters of the trigger; when the login parameters are an account number and a password, detecting whether there is a feedback token; when a first token with feedback is detected, adding the first token to a request header to obtain a verification token; sending the verification token to a designated platform for verification; when the login parameters are device parameters, determining a requesting device according to the device parameters; detecting whether the requesting device is in a preconfigured device list; when the requesting device is in the device list, detecting whether there is a feedback token; when a second token with feedback is detected, obtaining the time when the test case generation instruction is triggered by the requesting device as the trigger time; generating a random string; concatenating the second token, the device parameters, the trigger time and the random string to obtain a field to be verified; sending the field to be verified to the designated platform for verification; wherein the device list is used to store storing all devices with the authority to generate test cases; when the login parameter is an unknown interface parameter, determining the unknown interface according to the unknown interface parameter; obtaining the access key identifier and the initial key assigned to the unknown interface; encrypting the initial key to obtain the target key; sending the access key identifier and the target key to the designated platform for verification; wherein, encrypting the initial key to obtain the target key includes: in the T box corresponding to the initial key, splitting the initial key to obtain a preset number of key segments; for each key segment, obtaining a pre-constructed state transformation matrix; wherein the state transformation matrix is ​​used to scramble the row data and column data of each key segment; calculating the product of each key segment and the state transformation matrix to obtain each scrambled key segment; using the initial key to encrypt each scrambled key segment to obtain each key ciphertext; using the T box to process the key ciphertext, and obtaining the output data of the T box as the target key; When the test case generation instruction passes the verification, the requirement specification description document, the system implementation logic description document and the solution description document are obtained as the data to be processed according to the test case generation instruction; Inputting the data to be processed into a pre-trained test case generation model, and constructing a set of alternative use cases according to the output data of the test case generation model; Obtain a pre-configured mask rule, and use the mask rule to screen the test cases in the candidate case set to obtain at least one target test case; wherein, before obtaining the pre-configured mask rule, determine the test field according to the test case generation instruction, and determine the role of the triggerer in the test process; generate a test restriction condition according to the test field and the role; and generate the mask rule according to the test restriction condition; Before inputting the data to be processed into the pre-trained test case generation model, historical test cases are obtained, and training samples are constructed based on the historical test cases; the large language model is trained using the training samples; in each round of training, the value of the loss function of the round is obtained; when the value of the loss function reaches convergence, the training is stopped to obtain the test case generation model; Among them, the construction of training samples based on the historical test cases includes: obtaining use cases whose usage times are less than or equal to a preset number of times from the historical test cases to construct a first use case set; obtaining a current timestamp, and tracing back a preset time from the current timestamp to obtain a target timestamp; determining a time interval formed by the current timestamp and the target timestamp as a target time period; obtaining use cases whose usage times are greater than the preset number of times and anomalies are found within the target time period from the historical test cases to construct a second use case set; obtaining use cases whose usage times are greater than the preset number of times and no anomalies are found within the target time period from the historical test cases to construct a third use case set; obtaining training samples based on use case change information The first prediction model trained based on the use case usage information is used to predict each first use case in the first use case set, and the first prediction model is used to predict each first use case in the first use case set to obtain the predicted anomaly detection accuracy of each first use case; each first use case is arranged in descending order according to the anomaly detection accuracy of each first use case to obtain a first use case sequence; the configured accuracy threshold is obtained; the first use case sequence is split based on the accuracy threshold to obtain a first subsequence and a second subsequence; wherein the anomaly detection accuracy of each use case in the first subsequence is greater than the anomaly detection accuracy of each use case in the second subsequence; the second prediction model trained based on the use case usage information is obtained, and the second prediction model is used to predict each first use case in the second use case set The method comprises the following steps: predicting the second use case set according to the first and second use cases to obtain the anomaly detection accuracy of each predicted second use case; arranging each second use case in descending order according to the anomaly detection accuracy of each second use case to obtain a second use case sequence; splitting the second use case sequence based on the accuracy threshold to obtain a third subsequence and a fourth subsequence; wherein the anomaly detection accuracy of each use case in the third subsequence is greater than the anomaly detection accuracy of each use case in the fourth subsequence; obtaining the total number of times each third use case in the third use case set is used, and the number of times anomalies are detected during use; calculating the quotient of the number of times anomalies are detected and the total number of times used corresponding to each third use case to obtain the target indicator value corresponding to each third use case; and calculating the quotient of the number of times anomalies are detected and the total number of times used corresponding to each third use case. The target indicator values ​​corresponding to the third use cases are arranged in descending order for each third use case to obtain a third use case sequence; the third subsequence, the first subsequence, the second subsequence, the fourth subsequence and the third use case sequence are sequentially spliced ​​to obtain a target sequence; a preset proportion of use cases are extracted from the target sequence in a front-to-back order to construct the training sample; wherein, when the use cases are arranged using the anomaly detection accuracy, if there are two use cases with the same anomaly detection accuracy, the average duration of each test of the two use cases is calculated, and the use case with the smaller average duration is placed in front; if the average duration of each test of the two use cases is the same, any use case of the two use cases is placed in front.

2. The test case generation method according to claim 1, characterized in that: After obtaining at least one target test case, the method further includes: Feedback the at least one target test case to the triggerer; Detecting a selection operation, a modification operation, and a new addition operation of the at least one target test case by the triggerer; Receiving optimized test cases generated according to the selection operation and the modification operation, and receiving newly added test cases generated according to the newly added operation; Combining the optimized test case and the newly added test case to obtain a test case to be used; Testing is performed based on the test case to be used, and the test case generation model is optimized and trained using the test case to be used.

3. A test case generation device, the device executing the test case generation method according to any one of claims 1 to 2, characterized in that: The test case generating device comprises: A verification unit, configured to verify the test case generation instruction in response to the test case generation instruction; An acquisition unit, configured to acquire a requirement specification description document, a system implementation logic description document and a solution description document as data to be processed according to the test case generation instruction when the test case generation instruction passes verification; A construction unit, used for inputting the data to be processed into a pre-trained test case generation model, and constructing a set of alternative use cases according to the output data of the test case generation model; The screening unit is used to obtain a pre-configured mask rule and use the mask rule to screen the test cases in the candidate test case set to obtain at least one target test case.

4. A computer device, characterized in that: The computer device comprises: a memory storing at least one instruction; and A processor executes instructions stored in the memory to implement the test case generation method as described in any one of claims 1 to 2.

5. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the test case generation method as described in any one of claims 1 to 2.