Test case screening method, screening system, computer equipment and storage medium

By running test cases on test and online code, and filtering with coverage and running results, the problem of ineffective screening of test cases in the prior art is solved, reducing costs and improving test coverage.

CN111858292BActive Publication Date: 2024-11-12BEIJING DIDI INFINITY TECH & DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910865962.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-12
Publication Date
2024-11-12
Estimated Expiration
2040-09-25

AI Technical Summary

Technical Problem

In the existing software interface test, the test case screening method lacks effectiveness, resulting in high time and labor costs, and prone to incomplete coverage and missed testing.

Method used

By running multiple test cases on test code and online code, obtain coverage and run results, perform two filters, retain test cases that do not meet the requirements expectations, ensuring that changes in input and output are taken into account.

Benefits of technology

It reduces labor costs, improves the effectiveness of test case screening, avoids leaks, and ensures full coverage of tests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111858292B_ABST
    Figure CN111858292B_ABST
Patent Text Reader

Abstract

The present invention proposes a test case screening method, screening system, computer equipment and storage medium. The test case screening method includes: running multiple test cases on the test code to obtain the coverage of the test cases; screening multiple test cases according to the coverage of the test cases; running the screened test cases on the test code and the online code to obtain the test running results and the online running results of each test case; and screening the screened test cases again according to the test running results and the online running results. The test cases screened by the screening method of the technical solution of the present invention are then handed over to the testers for testing, which will greatly reduce the labor cost. The screening method of the technical solution of the present invention not only takes into account the input, but also decides whether to select the test case according to whether the output after the test case is run changes, thereby avoiding leaks and improving the effectiveness of screening.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a test case screening method, a screening system, a computer device and a storage medium. Background Art

[0002] In current software interface testing, in order to meet the requirements of business logic coverage, testers usually use a large number of test cases for coverage. The source of the test cases may be manually generated or generated by tools. For example, the system-level online traffic playback and the interface-level parameter optional range are used to generate test cases by permutation and combination. Usually, thousands of test cases are generated for a certain interface. If all these test cases are used for regression testing without screening, it will consume a lot of time and personnel costs. If there is screening, but it is only random screening, it may cause incomplete coverage and missed tests. In addition, most of the screening is purely manual screening or screening based on development tools, without considering whether the test case running results have an impact on the test case. Therefore, how to obtain effective test cases is particularly important for optimizing software engineering efficiency.

[0003] Currently, there are mainly the following methods for test case screening:

[0004] Random screening method: that is, randomly selecting some test cases for testing. This method of selecting test cases has no basis and specificity. The selection of test cases is random and prone to omissions.

[0005] Screening method based on business scenarios: The test cases generated by testers during interface testing are generally related to requirements, that is, the test cases are designed based on the requirements. Different requirements have different test cases, but this method cannot determine the effectiveness of the test, and the results are not convenient for intuitive measurement.

[0006] According to the coverage screening method: the coverage of all test cases is known. If the branch covered by a test case has been covered by other test cases, then the test case will not be selected. Each time a new test case is selected, only the test case that has newly covered the code branch will be selected. This method has a certain objectivity, but the number of test cases screened out may be very large, and some redundant test cases will be screened out. It only considers the input of the interface, and does not consider the output after the test case is run, nor does it consider whether the output changes after the test case changes. In addition, many of the screened test cases cannot reach the problematic code parts. The code parts reached by these redundant test cases are in line with expectations. Manually repeatedly checking the code that meets expectations will cause a waste of manpower. Summary of the invention

[0007] The present invention aims to solve at least one of the technical problems existing in the prior art or related art.

[0008] To this end, one aspect of the present invention is to propose a test case screening method.

[0009] Another aspect of the present invention is to provide a test case screening system.

[0010] Another aspect of the present invention provides a computer device.

[0011] Yet another aspect of the present invention provides a computer-readable storage medium.

[0012] In view of this, according to one aspect of the present invention, a test case screening method is proposed, including: running multiple test cases on the test code to obtain the coverage of the test cases; screening multiple test cases according to the coverage of the test cases; running the screened test cases on the test code and the online code to obtain the test running results and the online running results of each test case; and screening the screened test cases again according to the test running results and the online running results.

[0013] The test case screening method provided by the present invention performs a first screening of the test cases according to the coverage of the test cases, and then runs the test cases screened out for the first time on the test code and the online code respectively, and then performs a second screening of the test cases screened out for the first time according to the test running results and the online running results, and the retained test cases do not meet the expected demand, that is, the test cases that the tester needs to test. The test cases screened by the screening method of the technical solution of the present invention are then put into the hands of the tester for testing, which will greatly reduce the labor cost. The screening method of the technical solution of the present invention not only takes into account the input, but also decides whether to select the test case based on whether the output after the test case is run changes, thereby avoiding leak detection and improving the effectiveness of screening.

[0014] The test case screening method according to the present invention may also have the following technical features:

[0015] Furthermore, the step of screening multiple test cases according to the coverage of the test cases specifically includes: performing regression testing on the multiple test cases according to the coverage of the test cases until test cases that can achieve the coverage achieved by the multiple test cases are screened out.

[0016] In this technical solution, test cases that can achieve the coverage achieved by multiple test cases are screened out, which can ensure that the total branches traversed by the test cases screened out in the first round can be the same as the total branches traversed by all previous test cases. In addition, regression testing of all test cases can ensure comprehensive testing and avoid leaks.

[0017] Furthermore, the steps of performing regression testing on multiple test cases according to the coverage of the test cases until test cases that can achieve the coverage achieved by multiple test cases are screened out specifically include: recording the number of covered program branches and covered program branch information of each test case according to the coverage of the test cases; obtaining the test case with the largest number of covered program branches as the current test case; deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases; using the covered program branches of the current test case as a dimension, obtaining the Manhattan distance between the current test case and other test cases; updating the test case with the farthest Manhattan distance from the current test case as the current test case, and entering the step of deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases, until test cases that can achieve the coverage achieved by multiple test cases are screened out.

[0018] In this technical solution, according to the coverage rate of each test case, it is possible to accurately know which program branches each test case covers, and it is also possible to obtain how many program branches these test cases cover in total, and store the test cases and the program branches to which the test cases run. According to the coverage rate, first select the test case that covers the most program branches, and then delete the program branches covered by this test case from the program branch information of other test cases. The program branch information corresponding to the test case information will be updated, and it can be seen which program branches are not covered, and then select the second test case according to the multi-dimensional Manhattan farthest distance, so that all the previously covered program branches are covered. The method of selecting the second test case is specifically: treat each branch that the test case has walked through as a dimension, and the second test case is to select the test case with the farthest distance from the first test case in Manhattan distance, and then repeat the operation in the remaining test cases until the end. This can ensure that those redundant test cases that have repeatedly walked through the branches are deleted, and ensure that the least test cases can be screened out to walk to the most branches.

[0019] Furthermore, the step of re-screening the screened test cases according to the test running results and the online running results specifically includes: comparing the test running results with the online running results; and screening out the test cases whose test running results are different from the online running results.

[0020] In this technical solution, for the test cases screened by coverage, the corresponding test code and online code are accessed in turn to obtain the running results. Then the test running results are compared with the online running results to see if there are any differences. The test cases with different comparison results are the test cases that need to be screened out and are also the test cases finally obtained. That is, in the process of screening test cases, both the input must be considered and whether the output changes after the test case is run will be used to decide whether to select the test case.

[0021] According to another aspect of the present invention, a test case screening system is proposed, including: a processing unit, used to run multiple test cases on a test code to obtain the coverage of the test cases; screen multiple test cases according to the coverage of the test cases; run the screened test cases on the test code and the online code to obtain the test running results and the online running results of each test case; and screen the screened test cases again according to the test running results and the online running results.

[0022] The test case screening system provided by the present invention has a processing unit that performs a first screening of the test cases according to the coverage of the test cases, and then runs the test cases screened out of the first screening on the test code and the online code respectively, and then performs a second screening of the test cases screened out of the first screening according to the test running results and the online running results, and the retained test cases do not meet the expected demand, that is, the test cases that the tester needs to test. The test cases screened by the screening method of the technical solution of the present invention are then put into the hands of the tester for testing, which will greatly reduce the labor cost. The screening method of the technical solution of the present invention not only takes into account the input, but also decides whether to select the test case based on whether the output after the test case is run changes, thereby avoiding leak detection and improving the effectiveness of screening.

[0023] The test case screening system according to the present invention may also have the following technical features:

[0024] Furthermore, the processing unit screens the multiple test cases according to the coverage of the test cases, which specifically includes: performing regression testing on the multiple test cases according to the coverage of the test cases, until a test case that can achieve the coverage achieved by the multiple test cases is screened out.

[0025] In this technical solution, test cases that can achieve the coverage achieved by multiple test cases are screened out, which can ensure that the total branches traversed by the test cases screened out in the first round can be the same as the total branches traversed by all previous test cases. In addition, regression testing of all test cases can ensure comprehensive testing and avoid leaks.

[0026] Furthermore, the processing unit performs regression testing on multiple test cases according to the coverage of the test cases until test cases that can achieve the coverage achieved by multiple test cases are screened out, specifically including: recording the number of covered program branches and covered program branch information of each test case according to the coverage of the test cases; obtaining the test case with the largest number of covered program branches as the current test case; deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases; using the covered program branches of the current test case as a dimension, obtaining the Manhattan distance between the current test case and other test cases; updating the test case with the farthest Manhattan distance from the current test case as the current test case, and entering the step of deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases, until test cases that can achieve the coverage achieved by multiple test cases are screened out.

[0027] In this technical solution, according to the coverage rate of each test case, it is possible to accurately know which program branches each test case covers, and it is also possible to obtain how many program branches these test cases cover in total, and store the test cases and the program branches to which the test cases run. According to the coverage rate, first select the test case that covers the most program branches, and then delete the program branches covered by this test case from the program branch information of other test cases. The program branch information corresponding to the test case information will be updated, and it can be seen which program branches are not covered, and then select the second test case according to the multi-dimensional Manhattan farthest distance, so that all the previously covered program branches are covered. The method of selecting the second test case is specifically: treat each branch that the test case has walked through as a dimension, and the second test case is to select the test case with the farthest distance from the first test case in Manhattan distance, and then repeat the operation in the remaining test cases until the end. This can ensure that those redundant test cases that have repeatedly walked through the branches are deleted, and ensure that the least test cases can be screened out to walk to the most branches.

[0028] Furthermore, the processing unit re-screens the screened test cases according to the test running results and the online running results, specifically including: comparing the test running results with the online running results; and screening out the test cases whose test running results are different from the online running results.

[0029] In this technical solution, for the test cases screened by coverage, the corresponding test code and online code are accessed in turn to obtain the running results. Then the test running results are compared with the online running results to see if there are any differences. The test cases with different comparison results are the test cases that need to be screened out and are also the test cases finally obtained. That is, in the process of screening test cases, both the input must be considered and whether the output changes after the test case is run will be used to decide whether to select the test case.

[0030] According to another aspect of the present invention, a computer device is proposed, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of a test case screening method as described in any of the above technical solutions are implemented.

[0031] The computer device provided by the present invention implements the steps of the test case screening method of any of the above-mentioned technical solutions when the processor executes the computer program. Therefore, the computer device includes all the beneficial effects of the test case screening method of any of the above-mentioned technical solutions.

[0032] According to another aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the test case screening method of any of the above technical solutions are implemented.

[0033] The computer-readable storage medium provided by the present invention implements the steps of the test case screening method of any of the above-mentioned technical solutions when the computer program is executed by the processor. Therefore, the computer-readable storage medium includes all the beneficial effects of the test case screening method of any of the above-mentioned technical solutions.

[0034] Additional aspects and advantages of the present invention will become apparent from the following description or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0036] Figure 1 A schematic diagram showing a flow chart of a method for screening test cases according to a first embodiment of the present invention;

[0037] Figure 2 A schematic flow chart showing a method for screening test cases according to a second embodiment of the present invention;

[0038] Figure 3 A schematic flow chart showing a method for screening test cases according to a third embodiment of the present invention;

[0039] Figure 4 A schematic diagram showing a flow chart of a method for screening test cases according to a fourth embodiment of the present invention;

[0040] Figure 5 A schematic block diagram of a test case screening system according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0041] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.

[0042] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.

[0043] The embodiment of the first aspect of the present invention provides a method for screening test cases. The embodiments of this aspect are specifically described below:

[0044] Embodiment 1, Figure 1 The flowchart of the test case screening method of the first embodiment of the present invention is shown. The method includes:

[0045] Step 102: Run multiple test cases on the test code to obtain the coverage of the test cases.

[0046] Step 104: Screen multiple test cases according to the coverage of the test cases.

[0047] Step 106: Run the screened test cases on the test code and the online code to obtain the test running result and the online running result of each test case.

[0048] Step 108: re-screen the screened test cases according to the test running results and the online running results.

[0049] The test case screening method provided by the present invention performs a first screening of the test cases according to the coverage of the test cases, and then runs the test cases screened out for the first time on the test code and the online code respectively, and then performs a second screening of the test cases screened out for the first time according to the test running results and the online running results, and the retained test cases do not meet the expected demand, that is, the test cases that the tester needs to test. The test cases screened by the screening method of the technical solution of the present invention are then put into the hands of the tester for testing, which will greatly reduce the labor cost. The screening method of the technical solution of the present invention not only takes into account the input, but also decides whether to select the test case based on whether the output after the test case is run changes, thereby avoiding leak detection and improving the effectiveness of screening.

[0050] Embodiment 2: Figure 2 A schematic flow chart of a method for screening test cases according to a second embodiment of the present invention is shown. The method comprises:

[0051] Step 202: Run multiple test cases on the test code to obtain the coverage of the test cases.

[0052] Step 204 , performing regression testing on the multiple test cases according to the coverage of the test cases, until a test case that can achieve the coverage achieved by the multiple test cases is screened out.

[0053] Screening out test cases that can achieve the coverage of multiple test cases can ensure that the total branches traversed by the test cases screened out in the first round can be the same as the total branches traversed by all previous test cases. In addition, regression testing of all test cases can ensure comprehensive testing and avoid leaks.

[0054] Step 204 specifically includes: recording the number of covered program branches and covered program branch information of each test case according to the coverage of the test case; obtaining the test case with the largest number of covered program branches as the current test case; deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases; using the covered program branches of the current test case as a dimension, obtaining the Manhattan distance between the current test case and other test cases; updating the test case with the farthest Manhattan distance from the current test case as the current test case, and entering the step of deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases, until a test case that can achieve the coverage achieved by multiple test cases is screened out.

[0055] According to the coverage rate of each test case, we can accurately know which program branches each test case covers, and how many program branches these test cases cover in total, and store the test cases and the program branches where the test cases run. According to the coverage rate, first select the test case that covers the most program branches, and then delete the program branches covered by this test case from the program branch information of other test cases. The program branch information corresponding to the test case information will be updated, and you can see which program branches are not covered. Then select the second test case according to the multi-dimensional Manhattan maximum distance, and do this until all the previously covered program branches are covered. The method of selecting the second test case is as follows: treat each branch that the test case has passed through as a dimension, and the second test case is the test case that is the farthest from the first test case in Manhattan distance, and then repeat the operation in the remaining test cases until the end. In this way, it can be guaranteed that those redundant test cases that have repeatedly passed through branches are deleted, and it can be guaranteed that the least test cases can be screened out to reach the most branches.

[0056] Step 206: Run the screened test cases on the test code and the online code, and obtain the test running result and the online running result of each test case.

[0057] Step 208: re-screen the screened test cases according to the test running results and the online running results.

[0058] Embodiment 3, Figure 3 A schematic flow chart of a method for screening test cases according to a third embodiment of the present invention is shown. The method comprises:

[0059] Step 302: Run multiple test cases on the test code to obtain the coverage of the test cases.

[0060] Step 304: Screen multiple test cases according to the coverage of the test cases.

[0061] Step 304 specifically includes: recording the number of covered program branches and covered program branch information of each test case according to the coverage of the test case; obtaining the test case with the largest number of covered program branches as the current test case; deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases; using the covered program branches of the current test case as a dimension, obtaining the Manhattan distance between the current test case and other test cases; updating the test case with the farthest Manhattan distance from the current test case as the current test case, and entering the step of deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases, until a test case that can achieve the coverage achieved by multiple test cases is screened out.

[0062] Step 306: Run the screened test cases on the test code and the online code, and obtain the test running result and the online running result of each test case.

[0063] Step 308, compare the test running result with the online running result; filter out the test cases whose test running result is different from the online running result.

[0064] In this embodiment, for the test cases screened by coverage, the corresponding test code and online code are accessed in sequence to obtain the running results. Then the test running results are compared with the online running results to see if the results are different. The test cases with different comparison results are the test cases that need to be screened out and are also the test cases finally obtained. That is, in the process of screening test cases, both the input must be considered and whether the output changes after the test case is run to decide whether to select the test case.

[0065] Embodiment 4, the embodiment of the present invention proposes an application of a test case selection method based on an improved Manhattan algorithm in regression testing. In engineering, in order to solve the problem of test case screening, a factor of whether the test case will change the result after running is added to the test case screening process.

[0066] First, run all the generated test cases with the tool to get the coverage of each test case. Perform the first screening first. This screening is based on the idea of ​​multi-dimensional Manhattan maximum distance. The two-dimensional Manhattan distance is the sum of the distances of two dimensions. When extended to multi-dimensional, the principle is similar to the sum of the distances of multiple dimensions. When running the test cases, record the test cases and the branches that the test cases have passed through according to the coverage, and first select the test case that has passed through the most branches as the first test case. If the first test case is not the test case that has passed through the most branches, but is randomly selected, the screening result will be very unstable. Delete the branches covered by the first test case from the branch information of other test cases, and the branch information corresponding to the test case information will be updated, so that you can see which branches are not covered. After the first test case selection is fixed, the second test case should be selected as the test case that is "far" from the first test case, and select the second test case according to the multi-dimensional Manhattan maximum distance. Each branch that the test case has passed through is regarded as a dimension. The second test case is the test case that is the farthest from the first test case in Manhattan distance, and then repeat the operation in the remaining test cases until the end.

[0067] The total branch of the test cases selected in the first round can be guaranteed to be the same as the total branch of all previous test cases. Assuming that the returns obtained after running some of these test cases are the same as expected, it means that this part of the code meets the expected requirements, and those whose returns are different from expectations are effective test cases for testers. Run the test cases selected in the first round on both the test code and the online code to get the return results of the two. How to judge whether the return is the same as expected? You can compare the return of the test code and the online code to check whether there are different fields. If there are different fields, it is called a different return result. Record the test cases with different results, which are the key test cases for testers. The test case screening process does not use manpower. The most effective test cases are tested during the project testing process, so this method can save testing manpower costs.

[0068] Figure 4 A schematic flow chart of a method for screening test cases according to a fourth embodiment of the present invention is shown. The method comprises:

[0069] Step 402: Run the test case to obtain the coverage of a single test case.

[0070] Run the test cases first, so that you can get the coverage of each test case. You can know exactly which branches each test case covers, and how many branches these test cases cover in total. Store the test case information and the branches that the test cases run to.

[0071] In step 404, the test cases are screened for the first time based on Manhattan distance and coverage.

[0072] According to the branches obtained above, first select the test case that covers the most branches, and then delete the branches covered by this test case from the branch information of other test cases. The branch information corresponding to the test case information will be updated, and you can see which branches are not covered. Then select the second test case based on the maximum multi-dimensional Manhattan distance, and continue until all the previously covered branches are covered.

[0073] Step 406: Run the test cases selected for the first time on the test code and the online code, and then compare the results.

[0074] For the test case results filtered out above, access the corresponding code in turn to get the return value. Then compare the return value of the test code with the return value of the online code to see if there is any difference in the results.

[0075] Step 408, select test cases with different running results between the test code and the online code, and obtain the final test cases through a second screening.

[0076] The test cases that have different results from the comparison are the required test cases and are also the final test cases.

[0077] In this embodiment, the test cases are screened twice. In the regression test case screening, the test cases that can achieve the coverage of all test cases are first screened out according to the coverage. Then, based on the return results of the test cases in the test code and the online code, the similarities and differences between the two are compared. Based on the differences in the returned results, test cases that may not meet the expected requirements are screened out.

[0078] The embodiment of the second aspect of the present invention provides a test case screening system. Figure 5 A schematic block diagram of a test case screening system 500 according to an embodiment of the present invention is shown. The test case screening system 500 includes:

[0079] Processing unit 502 is used to run multiple test cases on the test code to obtain the coverage of the test cases; screen multiple test cases according to the coverage of the test cases; run the screened test cases on the test code and the online code to obtain the test running results and online running results of each test case; and screen the screened test cases again according to the test running results and the online running results.

[0080] The test case screening system 500 provided by the present invention, the processing unit 502 performs a first screening of the test cases according to the coverage of the test cases, and then runs the test cases screened out of the first screening on the test code and the online code respectively, and then performs a second screening of the test cases screened out of the first screening according to the test running results and the online running results, and the retained test cases do not meet the expected demand, that is, the test cases that the tester needs to test. The test cases screened by the screening method of the technical solution of the present invention are then put into the hands of the testers for testing, which will greatly reduce the labor cost. The screening method of the technical solution of the present invention not only takes into account the input, but also decides whether to select the test case based on whether the output after the test case is run changes, thereby avoiding leak detection and improving the effectiveness of screening.

[0081] Furthermore, the processing unit 502 screens the multiple test cases according to the coverage of the test cases, which specifically includes: performing regression testing on the multiple test cases according to the coverage of the test cases, until a test case that can achieve the coverage achieved by the multiple test cases is screened out.

[0082] In this embodiment, test cases that can achieve the coverage rate achieved by multiple test cases are screened out, which can ensure that the total branches traversed by the test cases screened out in the first round can be the same as the total branches traversed by all previous test cases. In addition, regression testing is performed on all test cases to ensure comprehensive testing and avoid leaks.

[0083] Further, the processing unit 502 performs regression testing on multiple test cases according to the coverage of the test cases until test cases that can achieve the coverage achieved by multiple test cases are screened out, specifically including: recording the number of covered program branches and covered program branch information of each test case according to the coverage of the test cases; obtaining the test case with the largest number of covered program branches as the current test case; deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases; using the covered program branches of the current test case as a dimension, obtaining the Manhattan distance between the current test case and other test cases; updating the test case with the farthest Manhattan distance from the current test case as the current test case, and entering the step of deleting the covered program branch information of the current test case contained in the covered program branch information of other test cases, until test cases that can achieve the coverage achieved by multiple test cases are screened out.

[0084] In this embodiment, according to the coverage rate of each test case, it is possible to accurately know which program branches each test case covers, and it is also possible to obtain how many program branches these test cases cover in total, and store the test cases and the program branches to which the test cases run. According to the coverage rate, the test case that covers the most program branches is first selected, and then the program branches covered by this test case are deleted from the program branch information of other test cases. The program branch information corresponding to the test case information will be updated, and it can be seen which program branches are not covered, and then the second test case is selected according to the multi-dimensional Manhattan maximum distance, so that all the previously covered program branches are covered. The method of selecting the second test case is specifically: each branch that the test case has passed is regarded as a dimension, and the second test case is the test case that is the farthest from the first test case in Manhattan distance, and then the operation is repeated in the remaining test cases until the end. In this way, it can be guaranteed that those redundant test cases that have repeatedly passed through the branches are deleted, and it is guaranteed that the least test cases can be screened out to reach the most branches.

[0085] Furthermore, the processing unit 502 re-screens the screened test cases according to the test running results and the online running results, specifically including: comparing the test running results with the online running results; and screening out the test cases whose test running results are different from the online running results.

[0086] In this embodiment, for the test cases screened by coverage, the corresponding test code and online code are accessed in sequence to obtain the running results. Then the test running results are compared with the online running results to see if the results are different. The test cases with different comparison results are the test cases that need to be screened out and are also the test cases finally obtained. That is, in the process of screening test cases, both the input must be considered and whether the output changes after the test case is run to decide whether to select the test case.

[0087] An embodiment of the third aspect of the present invention proposes a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the test case screening method as described in any of the above embodiments are implemented.

[0088] The computer device provided by the present invention implements the steps of the test case screening method of any of the above embodiments when the processor executes the computer program. Therefore, the computer device includes all the beneficial effects of the test case screening method of any of the above embodiments.

[0089] An embodiment of the fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the test case screening method as in any of the above embodiments.

[0090] The computer-readable storage medium provided by the present invention implements the steps of the test case screening method of any of the above embodiments when the computer program is executed by a processor. Therefore, the computer-readable storage medium includes all the beneficial effects of the test case screening method of any of the above embodiments.

[0091] In the description of this specification, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance unless otherwise clearly specified and limited; the terms "connection", "installation", "fixation" and the like should be understood in a broad sense, for example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be directly connected or indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0092] In the description of this specification, the description of the terms "one embodiment", "some embodiments", "specific embodiments", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0093] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for screening test cases, characterized in that: include: Run multiple test cases on the test code and obtain the test case coverage; Screening the multiple test cases according to the coverage of the test cases; Run the screened test cases on the test code and the online code, and obtain the test running result and the online running result of each of the test cases; Rescreen the screened test cases according to the test running results and the online running results; The step of screening the multiple test cases according to the coverage of the test cases specifically includes: Performing regression testing on the multiple test cases according to the coverage of the test cases until test cases that can achieve the coverage achieved by the multiple test cases are screened out; The step of re-screening the screened test cases according to the test running result and the online running result specifically includes: Comparing the test run result with the online run result; Filter out test cases whose test running results are different from the online running results.

2. The test case screening method according to claim 1, characterized in that: The step of performing regression testing on the multiple test cases according to the coverage of the test cases until a test case that can achieve the coverage achieved by the multiple test cases is screened out specifically includes: According to the coverage rate of the test case, record the number of covered program branches and covered program branch information of each test case; Obtain the test case with the largest number of covered program branches as the current test case; Deleting the coverage program branch information of the current test case contained in the coverage program branch information of other test cases; Taking the covered program branch of the current test case as a dimension, obtaining the Manhattan distance between the current test case and the other test cases; The test case with the farthest Manhattan distance from the current test case is updated as the current test case, and the step of deleting the coverage program branch information of the current test case contained in the coverage program branch information of other test cases is entered until a test case that can achieve the coverage rate achieved by the multiple test cases is screened out.

3. A test case screening system, characterized in that: include: A processing unit, used to run multiple test cases on the test code and obtain the coverage of the test cases; Screening the multiple test cases according to the coverage of the test cases; Run the screened test cases on the test code and the online code, and obtain the test running result and the online running result of each of the test cases; Rescreen the screened test cases according to the test running results and the online running results; The processing unit screening the multiple test cases according to the coverage of the test cases specifically includes: Performing regression testing on the multiple test cases according to the coverage of the test cases until test cases that can achieve the coverage achieved by the multiple test cases are screened out; The processing unit re-screening the screened test cases according to the test running result and the online running result specifically includes: Comparing the test run result with the online run result; Filter out test cases whose test running results are different from the online running results.

4. The test case screening system according to claim 3, characterized in that: The processing unit performs regression testing on the multiple test cases according to the coverage of the test cases until a test case that can achieve the coverage achieved by the multiple test cases is screened out specifically includes: According to the coverage rate of the test case, record the number of covered program branches and covered program branch information of each test case; Obtain the test case with the largest number of covered program branches as the current test case; Deleting the coverage program branch information of the current test case contained in the coverage program branch information of other test cases; Taking the covered program branch of the current test case as a dimension, obtaining the Manhattan distance between the current test case and the other test cases; The test case with the farthest Manhattan distance from the current test case is updated as the current test case, and the step of deleting the coverage program branch information of the current test case contained in the coverage program branch information of other test cases is entered until a test case that can achieve the coverage rate achieved by the multiple test cases is screened out.

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 test case screening method according to any one of claims 1 to 2 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 test case screening method according to any one of claims 1 to 2 are implemented.