Test case repair method, device, computer equipment and storage medium

By analyzing the failure reasons of test cases and selecting replacement data from the backup data set, the test case data is automatically replaced, which solves the problem of complexity and low efficiency of test case execution failure and achieves efficient automatic repair.

CN112363920BActive Publication Date: 2024-09-20GUANGZHOU PINWEI SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011231724.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-06
Publication Date
2024-09-20
Estimated Expiration
2040-11-06

AI Technical Summary

Technical Problem

In the existing technology, test cases often fail due to logic changes, data problems, or changes in test objects during execution, resulting in complex and inefficient repairs. Testers need to manually check and correct errors, which increases repair time.

Method used

By analyzing the failure reasons of test cases, if the use case data is abnormal, feature information is extracted and replacement data is selected from the backup test data set, and the use case data is automatically replaced to repair the failed test cases.

Benefits of technology

It realizes efficient automatic repair of test cases, reduces manual repair time and error search, and improves repair efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112363920B
    Figure CN112363920B
Patent Text Reader

Abstract

The present application relates to a method, device, computer equipment and storage medium for repairing a test case. The method comprises: obtaining a target test case, which is a test case whose number of execution failures meets a set condition; analyzing the cause of the test failure of the target test case; if the cause of the test failure is analyzed to be abnormality in the use case data, obtaining the use case data of the target test case, and extracting feature information from the use case data; selecting current replacement data from a spare test data set corresponding to the use case data according to the feature information; and replacing the use case data of the target test case with the current replacement data. The use of this method can reduce the time for test case repair and improve the efficiency of repair.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a test case repair method, device, computer equipment and storage medium. Background Art

[0002] With the development of software testing technology, in order to measure a special goal during the testing process, test cases are usually compiled. However, test cases often fail during execution, resulting in test failure.

[0003] Since there are many reasons for the failure of test case execution, such as changes in test case logic, problems with test case data, or changes in test objects, the repair methods for different test failure reasons are also complex and varied. In traditional technology, for test cases that fail to execute, errors are generally fed back to testers through a simple feedback mechanism, and testers are required to manually correct them. This not only requires extremely high error detection, error correction, and error correction capabilities of testers, but also greatly increases the time for test case repair and reduces the efficiency of repair. Summary of the invention

[0004] Based on this, it is necessary to provide a test case repair method, device, computer equipment and storage medium that can improve the repair efficiency of test cases in response to the above technical problems.

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

[0006] Obtain target test cases, where the target test cases are test cases whose execution failure times meet the set conditions;

[0007] Analyze the reasons for test failure of the target test cases;

[0008] If the reason for the test failure is analyzed to be abnormal use case data, the use case data of the target test case is obtained, and feature information is extracted from the use case data;

[0009] Selecting current replacement data from a backup test data set corresponding to the use case data according to the feature information;

[0010] Replace the test case data of the target test case with the current replacement data.

[0011] In one embodiment, extracting feature information from use case data includes:

[0012] Request feature information is extracted from the interface request data of the use case data.

[0013] In one embodiment, extracting feature information from use case data includes:

[0014] Extract response feature information from the interface response data of the use case data.

[0015] In one embodiment, extracting feature information from use case data includes:

[0016] Extract attribute feature information of use case data from the data attribute dimension.

[0017] In one embodiment, selecting current replacement data from a spare test data set corresponding to the use case data according to the feature information includes:

[0018] The feature information is converted into a feature vector, and the similarity between the backup test data in the backup test data set and the use case data is calculated according to the feature vector;

[0019] The current replacement data is selected from the spare test data whose similarity is greater than a preset threshold.

[0020] In one embodiment, before replacing the use case data of the target test case with the current replacement data, the method further includes:

[0021] Use the current replacement data as the test case data of the target test case, generate a test case to be verified, and verify whether the test case to be verified can be executed successfully;

[0022] If so, the step of replacing the test case data of the target test case with the current replacement data is performed.

[0023] In one embodiment, the method further includes:

[0024] If not, reselect replacement data from the backup test data set corresponding to the use case data according to the feature information, use the reselected replacement data as the current replacement data, and enter the step of using the current replacement data as the use case data of the target test case to generate a use case to be verified.

[0025] In one embodiment, the method further includes:

[0026] If not, first prompt information indicating that manual repair is needed is generated, and the first prompt information includes information indicating that the reason for the test failure is abnormal use case data.

[0027] In one embodiment, analyzing the test failure reasons of the target test case includes:

[0028] Acquire multiple execution data of target test cases; wherein the execution data includes test case data;

[0029] According to each execution data, the corresponding scoring model is called respectively, and each scoring model is used to score the data validity of each execution data;

[0030] Analyze the test failure reasons of the target test cases based on the scoring results of each scoring model.

[0031] In one embodiment, analyzing the test failure reasons of the target test case according to the scoring results of each scoring model includes:

[0032] Determine the weight of each execution data causing the target test case to fail to execute according to the scores of each scoring model;

[0033] The test failure cause of the target test case is determined based on the execution data with the largest weight.

[0034] In one embodiment, the method further includes:

[0035] If it is analyzed that the cause of the test failure is not abnormal use case data, a second prompt message is generated indicating that manual repair is required.

[0036] In one embodiment, the second prompt information includes the reason for the test failure.

[0037] In one embodiment, the method further includes: if it is analyzed that the cause of the test failure is not the use case data abnormality, calling other abnormality repair models that are not for the use case data abnormality to repair the target test case.

[0038] A test case repair device, the device comprising:

[0039] A target test case acquisition module is used to acquire a target test case, where the target test case is a test case whose execution failure times meet the set conditions;

[0040] Failure cause analysis module, used to analyze the test failure causes of target test cases;

[0041] The feature information extraction module is used to obtain the use case data of the target test case and extract feature information from the use case data if the reason for the test failure is analyzed to be abnormal use case data;

[0042] A replacement data selection module is used to select current replacement data from a spare test data set corresponding to the use case data according to feature information;

[0043] The use case data replacement module is used to replace the use case data of the target test case with the current replacement data.

[0044] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned repair steps of the test case when executing the computer program.

[0045] A computer-readable storage medium stores a computer program, which implements the above-mentioned test case repair steps when executed by a processor.

[0046] The above-mentioned test case repair method, device, computer equipment and storage medium can analyze the cause of the test failure of the target test case. When it is analyzed that the execution failure is caused by abnormal use case data, feature information can be extracted from the use case data of the target test case and replacement data can be screened out from the spare test data set based on the feature information, and the abnormal use case data can be replaced with the replacement data, thereby achieving the purpose of efficiently and automatically repairing the target test case. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 An application environment diagram of a repair method for a test case in an embodiment;

[0048] Figure 2 A flowchart of a method for repairing a test case in an embodiment;

[0049] Figure 3 A flowchart of steps for analyzing the cause of test failure of a target test case in one embodiment;

[0050] Figure 4 A technical architecture diagram for analyzing the test failure causes of a test case in an application embodiment;

[0051] Figure 5 A technical architecture diagram for repairing use case data of a test case in an application embodiment;

[0052] Figure 6 is a structural block diagram of a repair device for a test case in an embodiment;

[0053] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] The test case repair method provided in this application can be applied to Figure 1In the application environment shown. Among them, the server 102 pulls the target test case from the execution result message queue of the automated test platform 104, calls the test failure cause analysis model to analyze the test failure cause of the target test case, and if the test failure cause is analyzed to be abnormal use case data, obtains the use case data of the target test case, extracts feature information from the use case data, selects the current replacement data from the spare test data set corresponding to the use case data according to the feature information, and replaces the use case data of the target test case with the current replacement data. The server 102 can be implemented by an independent server or a server cluster composed of multiple servers.

[0056] In one embodiment, Figure 2 As shown, a test case repair method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0057] Step S10: Obtain a target test case, where the target test case is a test case whose number of execution failures meets a set condition.

[0058] The target test case is a test case whose number of execution failures meets the set conditions, and the set conditions can be set according to the test requirements.

[0059] Specifically, the interface automation testing platform will mark the test cases that fail to execute as failures. The server will pull the test cases that fail to execute from the case execution result message queue of the interface automation testing platform, and determine whether the number of times the test case fails to execute meets the set conditions based on its failure mark. If the number of times the test case fails to execute meets the set conditions, the test case will be used as the target test case.

[0060] Step S20: Analyze the test failure reasons of the target test case.

[0061] Among them, the test failure reason is the reason that causes the test case execution failure. Specifically, the reason for the test case execution failure can be analyzed through the data carried in the target test case or other intermediate data generated during the execution process. For example, the test failure reason for the target test case execution failure can be analyzed and evaluated from at least one dimension based on interface request data, interface response data, execution result data, execution environment data, system connectivity data, middleware status data, execution end service status data or response end service status data.

[0062] Step S30: If it is analyzed that the reason for the test failure is abnormal use case data, the use case data of the target test case is obtained, and feature information is extracted from the use case data.

[0063] The use case data refers to the test data used for interface testing in the test case, which may include interface request data and expected interface response data. Specifically, the use case data contains a large amount of test information, and feature information can be extracted from at least one dimension of the use case data according to preset conditions. The extraction method and the number of extracted features are not limited, but the extracted feature information should be basic information that reflects the characteristics of the use case data and can achieve the preset goals.

[0064] Step S40: selecting current replacement data from the spare test data set corresponding to the use case data according to the feature information.

[0065] The backup test data set includes multiple backup test data that can be used for interface testing. The backup test data can be from any source and can be test data manually input by the user or automatically recorded by the system during the interface history test. The current replacement data is the backup test data selected by the server from the backup test data set to replace the test case data in the target test case.

[0066] Specifically, the server can extract feature information of each backup test data in the backup test data set according to the extraction method and dimension of the use case data feature information of the target test case, and compare and analyze the feature information of the use case data with the feature information of each backup test data, so as to select the backup test data with similar feature information as the current replacement data.

[0067] Step S50: Use the current replacement data to replace the test case data of the target test case.

[0068] Specifically, the current replacement data selected from the spare test data is used to replace the use case data in the target test case, so as to repair the abnormal use case data of the target test case that failed to execute.

[0069] The above-mentioned test case repair method analyzes the reason for the test failure of the target test case. When it is analyzed that the execution failure is caused by abnormal use case data, feature information can be extracted from the use case data of the target test case and replacement data can be screened out from the backup test data set based on the feature information. The replacement data is used to replace the abnormal use case data, thereby achieving the purpose of efficiently and automatically repairing the target test case.

[0070] In one embodiment, extracting feature information from use case data includes: extracting request feature information from interface request data of the use case data.

[0071] In this embodiment, the request feature information of the use case data can be extracted from the request dimension of the interface. For example, feature extraction can be performed from at least one of the following aspects: 1. Request header; 2. Request method (for HTTP protocol type data); 3. Request body field type; 4. Request body field content; 5. Request body field weight. Interface request data is an important part of the use case data. Feature extraction from the request dimension of the interface can obtain information that fully reflects the use case request characteristics, improve the accuracy of subsequent replacement data selection, and thus improve the accuracy of abnormal use case data repair in the test case.

[0072] In one embodiment, extracting characteristic information from the use case data includes: extracting response characteristic information from interface response data of the use case data.

[0073] In this embodiment, the response feature information of the use case data can be extracted from the response dimension of the interface. For example, feature extraction can be performed from at least one of the following aspects: 1. Response header; 2. Response encoding (for HTTP protocol type data); 3. Response body field type; 4. Response body field content; 5. Response body field weight. Interface response data is an important part of the use case data. Feature extraction based on the response dimension of the interface can obtain information that fully reflects the use case response characteristics, improve the accuracy of subsequent replacement data selection, and thus improve the accuracy of abnormal use case data repair in the test case.

[0074] In one embodiment, extracting feature information from use case data includes: extracting attribute feature information of the use case data from a data attribute dimension.

[0075] In this embodiment, attribute feature information can be extracted from the data attribute dimension of the use case data. For example, feature extraction can be performed from at least one of the following aspects: 1. Data date; 2. Data source; 3. Data usage frequency; 4. Data success rate. Data attributes can reflect the characteristics of the data itself. Selecting replacement data from spare test data with similar attributes can improve the accuracy of selecting replacement data, thereby improving the accuracy of repairing abnormal use case data of the test case.

[0076] In one embodiment, current replacement data is selected from a backup test data set corresponding to the use case data according to feature information, including: converting the feature information into a feature vector, calculating the similarity between the backup test data in the backup test data set and the use case data according to the feature vector; and selecting current replacement data from the backup test data whose similarity is greater than a preset threshold.

[0077] In this embodiment, the feature information of the extracted target test case can be converted into a feature vector, and based on the feature vector and the feature vector of each spare test data in the spare test data set, the similarity between the case data and each spare test data is calculated using a similarity calculation method. By calculating the similarity between the case data and the spare test data, the feature information between the two can be digitized to make the relationship between the two clearer, so that replacement data can be selected from the spare test data more accurately. Among them, the similarity calculation method is not limited, and can be a Pearson correlation coefficient method.

[0078] Furthermore, according to the calculated similarity, spare test data with a similarity greater than a preset threshold may be used as candidate replacement data, and appropriate data may be further selected from the candidate replacement data in descending order of similarity as current replacement data.

[0079] In one embodiment, before replacing the use case data of the target test case with the current replacement data, the method also includes: using the current replacement data as the use case data of the target test case, generating a use case to be verified, and verifying whether the use case to be verified can be executed successfully; if so, executing the step of replacing the use case data of the target test case with the current replacement data.

[0080] In this embodiment, before replacing the use case data of the target test case with the current replacement data selected from the spare test data, the validity of the current replacement data can be verified first, that is, whether the current replacement data can restore the target test case to normal execution. Specifically, the current replacement data can be used as the use case data of the target test case to generate a test case, and the test case can be executed and verified. If the test case is executed successfully, it means that after replacing the use case data of the target test case with the current replacement data, the replaced target test case can be restored to normal operation. Therefore, the step of replacing the use case data of the target test case with the current replacement data can be executed. By adding the step of verifying the validity of the current replacement data, the accuracy of test case repair can be further improved.

[0081] In one embodiment, the above method also includes: if not, reselecting replacement data from the backup test data set corresponding to the use case data according to the feature information, using the reselected replacement data as the current replacement data, entering the step of using the current replacement data as the use case data of the target test case to generate a use case to be verified.

[0082] In this embodiment, if the validity verification of the current replacement data fails, it means that after using the current replacement data to replace the use case data of the target test case, the target test case cannot be restored to normal operation after the data replacement. Therefore, it is necessary to continue to reselect new replacement data from the backup test data, and use the reselected replacement data as the current replacement data again for validity verification until qualified replacement data is found in the backup test data set.

[0083] In one embodiment, if the generated use case to be verified fails to execute, a first prompt message indicating that manual repair is required may also be generated, and the first prompt message includes information indicating that the cause of the test failure is abnormal use case data. The first prompt message may further be sent to a terminal logged in by a tester to whom the target test case belongs. The tester may manually repair the test case based on the first prompt message. Since the first prompt message includes information indicating that the cause of the test failure is abnormal use case data, the tester does not need to perform additional error checking, and may directly perform repairs based on the first prompt message, thereby avoiding the problem of reduced repair efficiency due to time-consuming error checking.

[0084] Preferably, before generating a warning indicating that manual repair is needed, it is also possible to determine whether all the backup test data in the backup test data set whose similarity is greater than a preset threshold cannot be used as replacement data to replace the use case data of the target test case. If so, generate the first prompt information indicating that manual repair is needed.

[0085] In one embodiment, Figure 3 As shown, analyzing the cause of test failure of the target test case includes: step S202: obtaining multiple execution data of the target test case; wherein the execution data includes the use case data; step S204: calling the corresponding scoring model according to each execution data, and using each scoring model to score the data validity of each execution data; step S206: analyzing the cause of test failure of the target test case according to the scoring results of each scoring model.

[0086] In this embodiment, the validity of the data can be scored using a scoring model that analyzes and evaluates each type of execution data. According to the scoring results of each scoring model, the failure cause of the target test case can be more comprehensively understood, so as to more accurately select a repair strategy and improve the efficiency of failure repair.

[0087] Specifically, the execution data may include: use case data, execution environment data, system logic data, middleware status data, execution end service status data, and response end service status data, etc. The corresponding scoring models may include: use case data factor scoring model, environment factor scoring model, logic factor scoring model, middleware factor scoring model, execution end factor scoring model, and response end factor scoring model.

[0088] Among them, the use case data factor scoring model analyzes and scores the effectiveness of the use case data from at least one of the following aspects: 1. The date of the last change of the use case data; 2. The source of the use case data change (automatic system update or tester submission); 3. The execution success rate of the use case after the last change of the use case data; 4. The execution success rate of the use case before the last change of the use case data; 5. The difference fields before and after the last change of the use case data.

[0089] The environmental factor scoring model analyzes and scores the effectiveness of the execution environment data from at least one of the following aspects: 1. Test environment type; 2. Availability of the test environment; 3. Connectivity between interfaces involving systems.

[0090] The logic factor scoring model analyzes and scores the validity of the system logic data from at least one of the following aspects: 1. The date of the last change to the use case logic; 2. The current compilation status of the use case code; 3. The execution success rate after the last change to the use case logic; 4. The execution success rate before the last change to the use case logic; 5. The person who made the change to the use case logic; 6. The person who made the last change to the use case logic; 7. Changes to the use case logic code dependency packages.

[0091] The execution-end factor scoring model analyzes and scores the effectiveness of the execution-end service status data from at least one of the following aspects: 1. The server status of the execution end; 2. The network status of the execution end; 3. The running status of the test case of the execution end; 4. The test framework version of the test case running on the execution end; 5. The versions of each dependent package of the test case running on the execution end.

[0092] The response-end factor scoring model analyzes and scores the effectiveness of the response-end service status data from at least one of the following aspects: 1. The number of instances of the response-end service; 2. The availability of each instance of the response-end service; 3. The response delay of the overall response-end service; 4. The success rate of each instance of the response-end service; 5. The date of the most recent successful response of the same interface of the response end; 6. The response success rate of the same interface of the response end; 7. The date of the most recent deployment of the response-end service; 8. The date of the most recent change in the source code of the interface of the response end; 9. The date of the most recent successful response to the same request parameters after the most recent change in the source code of the interface of the response end.

[0093] In one embodiment, the cause of test failure of the target test case is analyzed according to the scoring results of each scoring model, including: determining the weight of each execution data causing the execution failure of the target test case according to the score of each scoring model; and determining the cause of test failure of the target test case according to the execution data with the largest weight.

[0094] In this embodiment, after calling multiple scoring tasks for different execution data and using the corresponding scoring model to score the effectiveness of each execution data, a comprehensive and comprehensive scoring result can be obtained. Among them, the execution data with a lower effectiveness score has a greater weight that causes the failure of the use case execution. The cause of the execution failure caused by the execution data with the largest weight is determined as the cause of the test failure. By combining the scores and calculating the weights, the cause of the failure can be obtained more accurately, thereby improving the accuracy of subsequent automatic repairs.

[0095] In one embodiment, the method further includes: if it is analyzed that the cause of the test failure is not the use case data anomaly, generating a second prompt message indicating that manual repair is required, or calling other anomaly repair models not targeting the use case data anomaly to repair the target test case.

[0096] In this embodiment, if the reason for the test failure is not abnormal use case data, a second prompt message indicating that manual repair is required can be generated to promptly remind the tester to perform manual repair. Other repair models can also be called. For example, if the reason for the test failure is abnormal middleware status data, a repair model for middleware status data can be called for automatic repair.

[0097] In one embodiment, the second prompt information may include the reason for the test failure. The tester can perform targeted repairs on the test case according to the reason for the test failure included in the second prompt information, without the need for additional error checking, and can directly perform repairs according to the first prompt information, thereby avoiding the problem of reduced repair efficiency due to time-consuming error checking.

[0098] Below, the repair method of the test case involved in this application is further explained in combination with an application example.

[0099] like Figure 4 As shown, Figure 4 The following is a technical framework diagram for analyzing the test failure causes of a test case in an application example, as described below:

[0100] (1) Set up a test case result listener to monitor the test result message queue of the automated testing platform, and determine the number of execution failures of the monitored test cases based on their failure marks.

[0101] (2) If the test case fails in the first execution, the failure mark is modified and a request to execute the test case again is sent to the automated testing platform.

[0102] (3) If it is not a test case that fails in the first execution, the test case can be determined as a target test case.

[0103] (4) Obtain the execution data of the target test case, and call multiple analysis tasks according to each execution data, where the analysis tasks may include: environment analysis task, middleware analysis task, execution end analysis task, response end analysis task, use case logic analysis task and use case data analysis task.

[0104] (5) Each analysis task uses a different scoring model to score the corresponding execution data. By comprehensively analyzing the scoring results of each scoring model, the test failure cause of the target test case execution failure can be determined and stored in the database.

[0105] (6) The analysis result monitoring task for monitoring the cause of test failure obtains the analysis result of the failure cause from the database, and calls the use case data repair task for the use case data anomaly or other repair tasks for non-use case data anomaly to automatically repair the target test case according to whether the cause of test failure is use case data anomaly.

[0106] like Figure 5 As shown, Figure 5 A technical architecture diagram for repairing the use case data of a test case in an application example is shown, as follows:

[0107] (1) The server retrieves the test case data of the target test case from the database and repairs the test case data.

[0108] (2) Extracting request features, response features, and data features from the use case data to generate a feature information set for the use case data.

[0109] (3) The server extracts request features, response features, and data features of each backup test data set from the backup test data set to form a feature information set of the backup test data.

[0110] (4) Based on the two feature information sets, compare the features of the use case data and other spare test data, and select the test data with the highest similarity to the use case data from the spare test data set as the current replacement data by calculating the similarity.

[0111] (5) Verify whether the current replacement data is valid. Specifically, use the selected current replacement data as the test case data of the target test case to generate a test case to be verified, execute the test case to be verified, and determine whether it can be executed successfully.

[0112] (6) If the test case to be verified is executed successfully, the test case data of the target test case is replaced with the current replacement data, and the tester to whom the test case belongs can be further notified that the replacement is successful.

[0113] (7) If the execution of the use case to be verified is unsuccessful, determine whether there is any test data in the backup test data set whose similarity is greater than the preset threshold. If so, reselect test data from these test data whose similarity is greater than the preset threshold as the current replacement data, and continue the step of verifying the current replacement data.

[0114] (8) If the test data in the backup test data set whose similarity is greater than the preset threshold value fails to be verified, the tester can be notified to perform manual repair.

[0115] It should be understood that although Figure 1-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0116] In one embodiment, Figure 6 As shown, a test case repair device is provided, comprising: a target case acquisition module 10, a failure cause analysis module 20, a feature information extraction module 30, a replacement data selection module 40 and a test case data replacement module 50, wherein:

[0117] The target test case acquisition module 10 is used to acquire a target test case, where the target test case is a test case whose execution failure times meet a set condition.

[0118] The failure cause analysis module 20 is used to analyze the test failure cause of the target test case.

[0119] The feature information extraction module 30 is used to obtain the use case data of the target test case and extract feature information from the use case data if it is analyzed that the cause of the test failure is abnormal use case data.

[0120] The replacement data selection module 40 is used to select current replacement data from the spare test data set corresponding to the use case data according to the feature information.

[0121] The use case data replacement module 50 is used to replace the use case data of the target test case with the current replacement data.

[0122] In one embodiment, the feature information extraction module 30 extracts request feature information from the interface request data of the use case data.

[0123] In one embodiment, the feature information extraction module 30 extracts response feature information from the interface response data of the use case data.

[0124] In one embodiment, the feature information extraction module 30 extracts attribute feature information of the use case data from the data attribute dimension.

[0125] In one embodiment, the replacement data selection module 40 converts the feature information into a feature vector, calculates the similarity between the backup test data in the backup test data set and the use case data according to the feature vector, and selects the current replacement data from the backup test data whose similarity is greater than a preset threshold.

[0126] In one embodiment, the replacement data selection module 40 is also used to use the current replacement data as the use case data of the target test case, generate a use case to be verified, and verify whether the use case to be verified can be executed successfully; if so, execute the step of replacing the use case data of the target test case with the current replacement data.

[0127] In one embodiment, the replacement data selection module 40 is further used to, if not, reselect replacement data from the spare test data set corresponding to the use case data according to the feature information, use the reselected replacement data as the current replacement data, enter the step of using the current replacement data as the use case data of the target test case, and generate a use case to be verified; or,

[0128] In one embodiment, the replacement data selection module 40 is further configured to generate a warning indicating that manual repair is required if no such repair is found.

[0129] In one embodiment, the failure cause analysis module 20 obtains multiple execution data of the target test case; wherein the execution data includes the use case data; calls the corresponding scoring model according to each execution data, and uses each scoring model to score the data validity of each execution data; analyzes the test failure cause of the target test case according to the scoring result of each scoring model.

[0130] In one embodiment, the failure cause analysis module 20 determines the weight of each execution data causing the target test case execution failure according to the scores of each scoring model; and determines the test failure cause of the target test case according to the execution data with the largest weight.

[0131] In one embodiment, the failure cause analysis module 20 is further configured to generate a warning indicating that manual repair is required if it is analyzed that the cause of the test failure is not abnormal use case data.

[0132] In one embodiment, the failure cause analysis module 20 is further used to call other anomaly repair models not targeting the use case data anomaly to repair the target test case.

[0133] The specific definition of the test case repair device can be found in the definition of the test case repair method above, which will not be repeated here. Each module in the above-mentioned test case repair device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0134] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store spare test data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a test case repair method is implemented.

[0135] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0136] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: obtaining a target test case, which is a test case whose number of execution failures meets a set condition; analyzing the cause of the test failure of the target test case; if it is analyzed that the cause of the test failure is abnormal use case data, obtaining use case data of the target test case and extracting feature information from the use case data; selecting current replacement data from a backup test data set corresponding to the use case data according to the feature information; and replacing the use case data of the target test case with the current replacement data.

[0137] In one embodiment, when the processor executes the computer program to extract feature information from the use case data, the following steps are specifically implemented: extracting request feature information from the interface request data of the use case data.

[0138] In one embodiment, when the processor executes the computer program to extract characteristic information from the use case data, the following steps are specifically implemented: extracting response characteristic information from the interface response data of the use case data.

[0139] In one embodiment, when the processor executes the computer program to extract feature information from the use case data, the following steps are specifically implemented: extracting attribute feature information of the use case data from the data attribute dimension.

[0140] In one embodiment, when the processor executes a computer program to select current replacement data from a backup test data set corresponding to the use case data based on feature information, the following steps are specifically implemented: converting the feature information into a feature vector, and calculating the similarity between the backup test data in the backup test data set and the use case data based on the feature vector; and selecting current replacement data from the backup test data whose similarity is greater than a preset threshold.

[0141] In one embodiment, before the processor executes a computer program to replace the use case data of the target test case with the current replacement data, it also implements the following steps: using the current replacement data as the use case data of the target test case, generating a use case to be verified, and verifying whether the use case to be verified can be executed successfully; if so, executing the step of replacing the use case data of the target test case with the current replacement data.

[0142] In one embodiment, the processor also implements the following steps when executing the computer program: if not, reselect replacement data from the backup test data set corresponding to the use case data based on the feature information, use the reselected replacement data as the current replacement data, and enter the step of generating a use case to be verified by using the current replacement data as the use case data of the target test case.

[0143] In one embodiment, when the processor executes the computer program, the following steps are further implemented: if not, a warning indicating that manual repair is required is generated.

[0144] In one embodiment, when a processor executes a computer program to implement analysis of the cause of test failure of a target test case, the following steps are specifically implemented: obtaining multiple execution data of the target test case; wherein the execution data includes the use case data; calling corresponding scoring models according to each execution data, and using each scoring model to perform data validity scoring on each execution data; and analyzing the cause of test failure of the target test case according to the scoring results of each scoring model.

[0145] In one embodiment, when the processor executes a computer program to analyze the test failure cause of the target test case according to the scoring results of each scoring model, the following steps are specifically implemented: the weight of each execution data causing the execution failure of the target test case is determined according to the score of each scoring model; the test failure cause of the target test case is determined according to the execution data with the largest weight.

[0146] In one embodiment, when the processor executes the computer program, the following steps are further implemented: if the cause of the test failure is not the abnormality of the use case data, a warning is generated indicating that manual repair is required. In one embodiment, when the processor executes the computer program, the following steps are further implemented: if the cause of the test failure is not the abnormality of the use case data, other abnormality repair models that are not for the abnormality of the use case data are called to repair the target test case.

[0147] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining a target test case, which is a test case whose number of execution failures meets a set condition; analyzing the test failure cause of the target test case; if it is analyzed that the test failure cause is abnormal use case data, obtaining use case data of the target test case and extracting feature information from the use case data; selecting current replacement data from a backup test data set corresponding to the use case data according to the feature information; and replacing the use case data of the target test case with the current replacement data.

[0148] In one embodiment, when the computer program is executed by a processor to extract feature information from use case data, the following steps are specifically implemented: extracting request feature information from interface request data of the use case data.

[0149] In one embodiment, when the computer program is executed by a processor to extract characteristic information from use case data, the following steps are specifically implemented: extracting response characteristic information from interface response data of the use case data.

[0150] In one embodiment, when the computer program is executed by a processor to extract feature information from use case data, the following steps are specifically implemented: extracting attribute feature information of the use case data from a data attribute dimension.

[0151] In one embodiment, when a computer program is executed by a processor to select current replacement data from a backup test data set corresponding to the use case data based on feature information, the following steps are specifically implemented: converting the feature information into a feature vector, and calculating the similarity between the backup test data in the backup test data set and the use case data based on the feature vector; and selecting current replacement data from the backup test data whose similarity is greater than a preset threshold.

[0152] In one embodiment, before the computer program is executed by the processor to replace the use case data of the target test case with the current replacement data, the following steps are also implemented: using the current replacement data as the use case data of the target test case, generating a use case to be verified, and verifying whether the use case to be verified can be executed successfully; if so, executing the step of replacing the use case data of the target test case with the current replacement data.

[0153] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: if not, reselecting replacement data from the backup test data set corresponding to the use case data according to the feature information, using the reselected replacement data as the current replacement data, and entering the step of using the current replacement data as the use case data of the target test case to generate a use case to be verified.

[0154] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: if not, a warning indicating that manual repair is required is generated.

[0155] In one embodiment, when a computer program is executed by a processor to analyze the cause of test failure of a target test case, the following steps are specifically implemented: obtaining multiple execution data of the target test case; wherein the execution data includes the use case data; calling corresponding scoring models according to each execution data, and using each scoring model to score the data validity of each execution data; analyzing the cause of test failure of the target test case according to the scoring results of each scoring model.

[0156] In one embodiment, when a computer program is executed by a processor to analyze the cause of test failure of a target test case according to the scoring results of each scoring model, the following steps are specifically implemented: the weight of each execution data causing the execution failure of the target test case is determined according to the score of each scoring model; and the cause of test failure of the target test case is determined according to the execution data with the largest weight.

[0157] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: if it is analyzed that the cause of the test failure is not abnormal use case data, a warning indicating that manual repair is required is generated.

[0158] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: if it is analyzed that the cause of the test failure is not the use case data exception, other exception repair models that are not for the use case data exception are called to repair the target test case.

[0159] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0160] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0161] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for repairing a test case, the method comprising: Obtain a target test case, where the target test case is a test case whose number of execution failures meets a set condition; Analyzing the test failure cause of the target test case, including: obtaining the execution data of the target test case, calling multiple analysis tasks according to each execution data, wherein the analysis task includes at least one of an environment analysis task, a middleware analysis task, an execution end analysis task, a response end analysis task, a use case logic analysis task, and a use case data analysis task; each analysis task uses a different scoring model to score the corresponding execution data, and comprehensively analyzes the scoring results of each scoring model to determine the test failure cause of the failure of the target test case to execute; If it is analyzed that the cause of the test failure is abnormal use case data, the use case data of the target test case is obtained, request feature information is extracted from the interface request data of the use case data, response feature information is extracted from the interface response data of the use case data, attribute feature information of the use case data is extracted from the data attribute dimension, and the request feature information, the response feature information and the attribute feature information are used as feature information of the use case data; The feature information is converted into a feature vector, and the similarity between the standby test data in the standby test data set and the use case data is calculated according to the feature vector, and the test data with the highest similarity to the use case data is selected from the standby test data set as the current replacement data through the similarity calculation, and the selected current replacement data is used as the use case data of the target test case to generate a use case to be verified, and the use case to be verified is executed to determine whether it can be executed successfully. If the use case to be verified is executed successfully, the use case data of the target test case is replaced with the current replacement data. If the use case to be verified is not executed successfully, it is determined whether there is any test data in the standby test data set whose similarity is greater than a preset threshold value, and if so, test data is reselected from these test data whose similarity is greater than the preset threshold value as the current replacement data; The use case data of the target test case is replaced with the current replacement data.

2. The method according to claim 1, characterized in that The analyzing the test failure reason of the target test case includes: Acquire multiple execution data of the target test case; wherein the execution data includes the test case data; According to each of the execution data, a corresponding scoring model is respectively called, and each of the execution data is scored for data validity using each scoring model; Analyzing the test failure reasons of the target test cases according to the scoring results of each of the scoring models; Analyzing the test failure reasons of the target test cases according to the scoring results of each of the scoring models includes: Determine the weight of each execution data causing the target test case to fail to execute according to the scores of each scoring model; The test failure reason of the target test case is determined according to the execution data with the largest weight.

3. The method according to claim 1, characterized in that The method further comprises: If it is analyzed that the reason for the test failure is not the use case data anomaly, a second prompt message indicating that manual repair is required is generated, or other anomaly repair models not targeting the use case data anomaly are called to repair the target test case; the second prompt message includes the reason for the test failure.

4. A test case repair device, characterized in that: The device comprises: A target test case acquisition module is used to acquire a target test case, wherein the target test case is a test case whose execution failure times meet a set condition; A failure cause analysis module is used to analyze the test failure cause of the target test case, specifically to obtain the execution data of the target test case, and to call multiple analysis tasks according to each execution data, wherein the analysis task includes at least one of an environment analysis task, a middleware analysis task, an execution end analysis task, a response end analysis task, a use case logic analysis task, and a use case data analysis task; each analysis task uses a different scoring model to score the corresponding execution data, and comprehensively analyzes the scoring results of each scoring model to determine the test failure cause of the failure of the target test case to execute; A feature information extraction module is used to obtain the use case data of the target test case if it is analyzed that the cause of the test failure is abnormal use case data, extract request feature information from the interface request data of the use case data, extract response feature information from the interface response data of the use case data, extract attribute feature information of the use case data from the data attribute dimension, and use the request feature information, the response feature information and the attribute feature information as feature information of the use case data; A replacement data selection module, used to convert the feature information into a feature vector, calculate the similarity between the standby test data in the standby test data set and the use case data according to the feature vector, and select the test data with the highest similarity to the use case data from the standby test data set as the current replacement data by calculating the similarity, use the selected current replacement data as the use case data of the target test case to generate a use case to be verified, execute the use case to be verified, and determine whether the execution is successful. If the execution of the use case to be verified is successful, replace the use case data of the target test case with the current replacement data. If the execution of the use case to be verified is unsuccessful, determine whether there is any test data in the standby test data set whose similarity is greater than a preset threshold. If so, reselect test data from these test data whose similarity is greater than the preset threshold as the current replacement data; A use case data replacement module is used to replace the use case data of the target test case with the current replacement data.

5. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.