A program testing method and apparatus

By selecting test cases with a high probability of missing tests for regression testing, the problem of excessively long testing time in existing technologies is solved, and testing efficiency is improved.

CN113076255BActive Publication Date: 2025-10-28BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110416225.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-19
Publication Date
2025-10-28
Estimated Expiration
2041-04-19

AI Technical Summary

Technical Problem

Existing technologies, when performing regression testing after program modifications, use the same set of test cases, resulting in excessively long testing times and low testing efficiency.

Method used

By obtaining the test case set of the missed test probability of the modified program, the test cases with the missed test probability greater than the preset threshold are selected to form a regression test case set, and the test case set is used for testing.

Benefits of technology

This reduced testing time and improved testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113076255B_ABST
    Figure CN113076255B_ABST
Patent Text Reader

Abstract

This application provides a program testing method and apparatus. The method includes: obtaining a set M of test cases with the probability of missed tests corresponding to the Nth modification of the program. N Based on the type of the statement that modifies the program in the (N+1)th iteration, and M N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 Get M N+1 Test cases with a missed detection probability greater than a preset threshold are used to form a regression test case set. This regression test case set is then used to test the program after the (N+1)th modification. The missed detection probability test case set includes test cases and their corresponding missed detection probabilities. This method can reduce testing time and improve testing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a program testing method and apparatus. Background Technology

[0002] During the requirements development process, frequent iterations of requirements often occur, and the code is frequently modified. Testers then need to perform regression testing on the modified code to prevent the modified code from causing new problems.

[0003] For scenarios involving only functional optimization or bug fixes, existing technologies directly use the same test case set as before the program was modified for regression testing.

[0004] In the process of implementing this application, the inventors found that after each program modification, regression testing using all test cases took a long time and resulted in low testing efficiency. Summary of the Invention

[0005] In view of this, this application provides a program testing method and apparatus that can reduce testing time and improve testing efficiency.

[0006] To solve the above-mentioned technical problems, the technical solution of this application is implemented as follows:

[0007] In one embodiment, a program testing method is provided, the method comprising:

[0008] Obtain the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N The test case set for the probability of missed tests includes test cases and the probability of missed tests corresponding to each test case.

[0009] Based on the type of the statement that modifies the program in the (N+1)th time, and M N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 ;

[0010] Get M N+1 The test cases with a missed detection probability greater than a preset threshold constitute the regression test case set;

[0011] The program after the N+1th modification was tested using the regression test case set.

[0012] In another embodiment, a program testing apparatus is provided, the apparatus comprising: a first acquisition unit, a determination unit, a second acquisition unit, and a testing unit;

[0013] The first acquisition unit is used to acquire the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. NThe test case set for the probability of missed tests includes test cases and the probability of missed tests corresponding to each test case.

[0014] The determining unit is configured to determine the type of the statement that modifies the program for the (N+1)th time, and the M obtained by the first obtaining unit. N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 ;

[0015] The second acquisition unit is used to acquire the M determined by the determining unit. N+1 The test cases with a missed detection probability greater than a preset threshold constitute the regression test case set;

[0016] The testing unit is used to test the program after the N+1th modification using the regression test case set obtained by the second acquisition unit.

[0017] In another embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the program testing method.

[0018] In another embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps of the program testing method.

[0019] As can be seen from the above technical solution, in the above embodiments, a set of test cases with a missed detection probability of the modified program is obtained, and test cases with a missed detection probability greater than a preset probability are selected to form a regression test case set. The modified program is then tested using the regression test case set. This solution can reduce testing time and improve testing efficiency. Attached Figure Description

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0021] Figure 1 This is a flowchart illustrating the process of determining the probability of missed tests for each test case in the test case set in this embodiment of the application.

[0022] Figure 2 This is a schematic diagram of the program testing process in an embodiment of this application;

[0023] Figure 3This is a flowchart illustrating the process of determining the test case set for the missed detection probability corresponding to the modified program in this embodiment of the application.

[0024] Figure 4 This is a schematic diagram of the program testing device structure in an embodiment of this application;

[0025] Figure 5 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

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

[0027] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0028] The technical solution of the present invention will be described in detail below with reference to specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0029] This application provides a program testing method applied to scenarios involving regression testing after program functional optimization or bug fixes. The method involves obtaining a set of test cases with a missed detection probability for the modified program, selecting test cases with a missed detection probability greater than a preset probability to form a regression test case set, and then using this regression test case set to test the modified program. This approach reduces testing time and improves testing efficiency.

[0030] In this embodiment of the application, when testing the original, i.e., unmodified program, the approach is consistent with the existing implementation; the written test case set can be used directly for testing.

[0031] The new addition in this embodiment is the requirement to generate a set of test cases M0 for the unmodified program before testing it online, prior to any modifications or testing of the modified program. This set of test cases includes test cases and their corresponding probability of failure. The specific generation method is as follows:

[0032] Obtain a test case set for testing the unmodified program, estimate the probability of missing tests for each test case in the test case set, and form a test case set M0 with the probability of missing tests for the unmodified program.

[0033] The probability of a test case missing a test is the probability that no defect is found after executing the test case, but a defect appears after the test is run online. The specific implementation for obtaining the probability of missing a test for each test case is as follows:

[0034] See Figure 1 , Figure 1 This is a flowchart illustrating the process of determining the probability of missed tests for each test case in the test case set in this embodiment of the application. The specific steps are as follows:

[0035] Step 101: Obtain the test case set for testing the unmodified program.

[0036] Step 102: Obtain the probability of the statement that covers the error, the probability of the intermediate state of the error occurring, and the probability of outputting the error result for each test case in the test case set.

[0037] The probability of covering the erroneous statement is the probability of covering the corresponding erroneous statement when the test case is executed.

[0038] In this embodiment of the application, obtaining the probability of the statement with the coverage error includes:

[0039] Perform a static scan of the program to identify erroneous statements;

[0040] During the execution of each test case, instrumentation is used to record the executed and unexecuted statements;

[0041] The probability that the test case executes the statement corresponding to the error is the probability that the test case covers the statement with the error.

[0042] Among them, static scanning of the program can be performed using sonarQube; check whether the scanned error program is executed. If the error program is covered, determine that the probability of the corresponding error statement being covered in this execution is 1, that is, the probability of the test case covering the error statement is 1.

[0043] The probability of an erroneous intermediate state is the probability that an erroneous statement will produce an erroneous intermediate state after being executed.

[0044] In this embodiment of the application, obtaining the probability of the occurrence of the intermediate state of the error includes:

[0045] Obtain the probability of an intermediate state of error occurring for the test case settings.

[0046] Executing a test case may result in the execution of an erroneous statement, but this doesn't necessarily lead to an intermediate state of error. The probability of this intermediate state can be determined from statistical experimental data. After a system deployment, the executed test case can be reviewed to check for the occurrence of an intermediate state of error, thus providing the probability of this occurrence. Alternatively, for specific scenarios, empirical estimation can be used. For example, if a tester has reviewed a section of the development code, they can estimate the probability of an intermediate state of error when writing a test case for verification.

[0047] Regardless of how the error intermediate state of the test case is obtained, the probability of its occurrence will be set and stored. When needed, the set value can be retrieved directly.

[0048] The probability of outputting an incorrect result is the probability that an intermediate state of error is generated after the erroneous statement is executed, and the output result of the intermediate state of error is incorrect after execution.

[0049] In this embodiment of the application, obtaining the probability of the output error result includes:

[0050] When an erroneous intermediate result is used computationally, the probability of the intermediate result being erroneous is taken as the probability of the output being erroneous.

[0051] If the intermediate result variable is incorrect, and this variable happens to be used as an input parameter for another method, then the result returned by that method will definitely be incorrect. In other words, the probability of an intermediate result being incorrect is closely related to the probability of the output result. Therefore, the probability of an intermediate result being incorrect can be approximated as the probability of an output result being incorrect. In the implementation of this application, the probability of an intermediate result being incorrect is used as the probability of an output result being incorrect.

[0052] When an erroneous intermediate result is used as a control branch of the control flow, the product of the probabilities of whether all branch expressions are erroneous is used as the probability of outputting an erroneous result.

[0053] Control flow usage refers to the use of intermediate state results as a form of control flow.

[0054] When an incorrect intermediate state value is used in a branch statement conditional expression, it will lead to an error in the program execution path. Therefore, the factor affecting the execution result is whether the branch statement expression executes incorrectly. Thus, the product of the probabilities of all branch expressions being incorrect can be used as the probability of error in the output result.

[0055] The probability of whether a branch expression is incorrect is calculated by first finding all executed branch expressions. After the system goes live, a specific test case is checked to see if it executed the incorrect program and produced an incorrect intermediate state. Then, the value of the incorrect intermediate state is used to estimate the probability of whether the branch statement expression was executed.

[0056] Step 103: Determine the missed test probability of the test case as the product of the probability of the statement with the covered error, the probability of the intermediate state of the error occurring, and the probability of the output error result.

[0057] This gives us the test case set for the missed detection probability corresponding to the 0th modified program, i.e., the unmodified program.

[0058] The following section, with reference to the accompanying diagrams, details the process of testing the modified program.

[0059] See Figure 2 , Figure 2 This is a schematic diagram of the program testing process in an embodiment of this application. Specific steps:

[0060] Step 201: Obtain the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N .

[0061] When acquiring the test cases, you can either determine and use them directly when needed, or you can estimate the storage in advance and directly acquire the test case set with the probability of missing tests when using it.

[0062] In this embodiment, N is an integer not less than 0. When N is 0, it refers to the program after the 0th modification, that is, the test case set for the missed detection probability corresponding to the original program.

[0063] When N is 0, obtain a test case set for testing the unmodified program, estimate the probability of missing tests for each test case in the test case set, and form a test case set for the missing test probability corresponding to the unmodified program.

[0064] When N is 1, the test case set M1 corresponding to the missed test probability of the program after the first modification is obtained according to the type of statement that was modified in the first modification and the test case set for missed test probability of the unmodified program.

[0065] When N is an integer greater than 1, the test case set M is determined based on the type of the statement modified in the (N-1)th time and the probability of missed tests corresponding to the modified program. N-1 Obtain the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N .

[0066] Step 202, based on the type of the statement that modifies the program in the (N+1)th time, and M N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 .

[0067] The following section, in conjunction with the accompanying diagram, details how to determine the test case set for the missed detection probability of the modified program based on the test case set for the missed detection probability of the original program.

[0068] Statement types include: arithmetic statements and flow control statements;

[0069] In Java, arithmetic statements refer to statements that contain operators, such as arithmetic operators, assignment operators, increment / decrement operators, logical operators, and ternary operators.

[0070] Flow control statements include sequential structures, branching structures (if, switch), and loop structures (for, while, do…while).

[0071] To determine if the memory is consistent, if it is stored in stack memory and heap memory respectively, then it is determined that it is stored in different memory locations; if it is stored in stack memory or heap memory respectively, then it is determined that the memory is the same.

[0072] The Java Virtual Machine (JVM) memory includes heap memory, stack memory, program counter, and local variables are stored in stack memory. Objects created using `new` are stored in heap memory, and the program counter stores and records the bytecode instructions of the program.

[0073] See Figure 3 , Figure 3 This is a flowchart illustrating the process of determining the test case set for the missed detection probability corresponding to the modified program in this embodiment of the application. The specific steps are as follows:

[0074] Step 301: Determine the type of the modified statement and the storage location of the intermediate results.

[0075] Step 302: When the modified statement is an operation statement and the intermediate results are in the same memory location, M... N As M N+1 End of this process.

[0076] The modified statement is an operational statement, and the intermediate results of executing this statement before and after the modification reside in the same memory. This allows the probability of missed tests in the test case set corresponding to the original program to be approximately equal to the probability of missed tests in the test case set corresponding to the modified program.

[0077] Here are some examples:

[0078] The modified statement is x, which is an operation statement, such as x = a + b. The intermediate results generated by executing this statement in both the pre- and post-modification programs reside in the same stack memory. M... N As M N+1 This means that the probability of missing a test case remains constant.

[0079] Step 303: When the modified statement is an operation statement and the intermediate results are not in the same memory location, M N+1 The probability of missing tests corresponding to the test cases in the middle is 1 and M. N The difference between the missed test probabilities of the corresponding test cases. End of this process.

[0080] The modified statement is an arithmetic statement, and the intermediate results of executing this statement before and after the modification are stored in different memory locations. This allows the difference between the missed test probabilities of the test cases corresponding to 1 and the original program to be used as the missed test probability of the modified test case.

[0081] Specifically, the original statement was the operation x = a + b, which stored the value of a + b in x. The modified statement is y = a × b. This modified statement does not assign a value to x, but it does assign a value to y. Therefore, when the operation statement is executed, the values ​​stored in both variables x and y change. The probability of missing a test case for the modified program is: 1 - the probability of missing a test case before the modification.

[0082] Step 304: When the type of the modified statement is a flow control statement, set M... N As M N+1 .

[0083] When the modified statement is a flow control statement, the execution path may change before and after the modification. However, it can reflect the effectiveness of each test case in testing the modified statement to a certain extent. (M) N As M N+1 This means that the probability of missing a test case remains constant.

[0084] In this step, after determining M N+1 In addition to being used to determine the regression test set at present, it can also be stored so that it can be directly retrieved for determining regression test cases when the program is modified in the (N+2)th time.

[0085] Step 203, obtain M N+1 The regression test case set consists of test cases with a missed detection probability greater than a preset threshold.

[0086] The preset threshold can be set according to actual needs or experience, such as 60%, but this application embodiment does not limit this.

[0087] Filtering out test cases with a missed test probability of no more than a preset threshold can reduce the number of test cases.

[0088] Step 204: Test the N+1th modified program using the regression test case set.

[0089] In this embodiment, a test case set with high failure rates is generated by evaluating the probability of each test case missing after deployment. This set is then used to evaluate the probability of each test case failing to pass a test in the modified program. By identifying these two key points, test cases with high failure rates are selected to generate a new regression test case set, thereby reducing the number of test cases in the regression test case set. Using the regression test case set obtained in this application to test the modified program reduces testing time and improves testing efficiency.

[0090] Based on the same inventive concept, this application also provides a program testing device. See also Figure 4 , Figure 4 This is a schematic diagram of the program testing device structure in an embodiment of this application. The device includes: a first acquisition unit 401, a determination unit 402, a second acquisition unit 403, and a testing unit 404;

[0091] The first acquisition unit 401 is used to acquire the test case set M corresponding to the missed test probability of the program after the Nth modification. N The test case set for the probability of missed tests includes test cases and the probability of missed tests corresponding to each test case.

[0092] Determining unit 402 is used to determine the type of the statement that modifies the program for the (N+1)th time, and the M obtained by the first obtaining unit 401. N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 ;

[0093] The second acquisition unit 403 is used to acquire the M determined by the determination unit 402. N+1 The test cases with a missed detection probability greater than a preset threshold constitute the regression test case set;

[0094] Test unit 404 is used to test the program after the N+1th modification using the regression test case set obtained by the second acquisition unit 403.

[0095] Preferably, the device further includes: a storage unit;

[0096] The storage unit is used to store the test case set M corresponding to the N+1th modified program determined by the determining unit 402, which contains the probability of missed tests. N+1 storage.

[0097] Preferably,

[0098] The first acquisition unit 401 is specifically used to acquire the test case set for the probability of missed tests corresponding to the Nth modified program, including: when N is 0, acquiring the test case set for testing the unmodified program, estimating the probability of missed tests for each test case in the test case set, and forming the test case set for the probability of missed tests corresponding to the unmodified program; when N is 1, acquiring the test case set for the probability of missed tests corresponding to the first modified program based on the type of the statement modified in the first modification and the test case set for the probability of missed tests corresponding to the unmodified program; when N is an integer greater than 1, acquiring the test case set for the probability of missed tests M1 corresponding to the first modified program based on the type of the statement modified in the (N-1)th modification and the test case set for the probability of missed tests M1 corresponding to the (N-1)th modified program. N-1 Obtain the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N .

[0099] Preferably,

[0100] The first acquisition unit 401 is specifically used to acquire a test case set for testing the unmodified program. When estimating the missed test probability for each test case in the test case set, the acquisition includes: acquiring the test case set for testing the unmodified program; acquiring the probability of covering the incorrect statement, the probability of the incorrect intermediate state occurring, and the probability of outputting an incorrect result for each test case in the test case set; and determining that the missed test probability of the test case is the product of the probability of covering the incorrect statement, the probability of the incorrect intermediate state occurring, and the probability of outputting an incorrect result.

[0101] Preferably,

[0102] The first acquisition unit 401 is specifically used to perform static scanning of the program to acquire erroneous statements; during the execution of each test case, it uses instrumentation to record executed and unexecuted statements; it determines the probability that the test case executes the corresponding erroneous statement as the probability that the test case covers the erroneous statement; it acquires the probability of the occurrence of the intermediate state of the error set for the test case; when the intermediate state result of the error is used as a computation, the error probability of the intermediate state result is used as the probability of outputting the erroneous result; when the intermediate state result of the error is used as a control branch of the control flow, the product of the probabilities of whether all branch expressions are erroneous is used as the probability of outputting the erroneous result.

[0103] Preferably,

[0104] Determining unit 402 is specifically used to determine the type of the statement that modifies the program for the (N+1)th time, and M N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 This includes situations where the modified statement is an arithmetic statement and the intermediate results reside in the same memory location, in which case M will be... N As M N+1 When the modified statement is an operation statement, and the intermediate results are not in the same memory location, M N+1 The probability of missing tests corresponding to the test cases in the middle is 1 and M. N The difference between the missed test probabilities of the corresponding test cases; when the modified statement is a flow control statement, M will be... N As M N+1 .

[0105] The units in the above embodiments can be integrated into one unit or deployed separately; they can be merged into one unit or further divided into multiple sub-units.

[0106] In another embodiment, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the program testing method.

[0107] In another embodiment, a computer-readable storage medium is also provided, on which computer instructions are stored, which, when executed by a processor, can implement the steps in the program testing method.

[0108] Figure 5 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention. Figure 5As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute the following methods:

[0109] Obtain the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N ;

[0110] Based on the type of the statement that modifies the program in the (N+1)th time, and M N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 ;

[0111] Get M N+1 The test cases with a missed detection probability greater than a preset threshold constitute the regression test case set;

[0112] The program after the N+1th modification was tested using the regression test case set described above;

[0113] The test case set for the probability of missed tests includes test cases and the probability of missed tests corresponding to each test case.

[0114] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0115] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0116] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0117] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A program testing method, characterized in that, The method includes: Obtain the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N The test case set for the probability of missed detection includes test cases and the probability of missed detection corresponding to each test case; wherein, the step of obtaining the test case set M for the probability of missed detection corresponding to the Nth modified program is... N The process includes: when N is 0, obtaining a test case set for testing the unmodified program, estimating the probability of missed tests for each test case in the test case set, and forming a test case set with missed test probability corresponding to the unmodified program; obtaining the test case set for testing the unmodified program and estimating the probability of missed tests for each test case in the test case set includes: obtaining the test case set for testing the unmodified program; obtaining the probability of covering the incorrect statement, the probability of the incorrect intermediate state occurring, and the probability of outputting an incorrect result for each test case in the test case set; determining that the probability of missed tests for the test case is the product of the probability of covering the incorrect statement, the probability of the incorrect intermediate state occurring, and the probability of outputting an incorrect result; Based on the type of the statement that modifies the program in the (N+1)th time, and M N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 ; Get M N+1 The test cases with a missed detection probability greater than a preset threshold constitute the regression test case set; The program after the N+1th modification was tested using the regression test case set.

2. The method according to claim 1, characterized in that, The method further includes: The test case set M corresponding to the N+1th modified program will be used to determine the probability of missed detections. N+1 storage.

3. The method according to claim 1, characterized in that, To obtain the test case set for the missed detection probability corresponding to the Nth modified program, it also includes: When N is 1, the test case set M1 corresponding to the missed test probability of the program after the first modification is obtained according to the type of statement that was modified in the first modification and the test case set for missed test probability of the unmodified program. When N is an integer greater than 1, the test case set M is determined based on the type of the statement modified in the Nth modification and the missed test probability of the program after the (N-1)th modification. N-1 Obtain the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N .

4. The method according to claim 1, characterized in that, The process of obtaining the probability of the statement covering the error, the probability of the intermediate state of the error occurring, and the probability of outputting an error result for each test case in the test case set includes: The probability of obtaining the statement with the coverage error includes: Perform a static scan of the program to identify erroneous statements; During the execution of each test case, instrumentation is used to record the executed and unexecuted statements; The probability that the test case executes the statement corresponding to the error is determined as the probability that the test case covers the statement with the error. Obtaining the probability of the intermediate state of the error occurring includes: Obtain the probability of an intermediate state of error occurring for the test case settings; The probability of obtaining the output error result includes: When an erroneous intermediate result is used computationally, the probability of the intermediate result being erroneous is taken as the probability of the output being erroneous. When an erroneous intermediate result is used as a control branch of the control flow, the product of the probabilities of whether all branch expressions are erroneous is used as the probability of outputting an erroneous result.

5. The method according to any one of claims 1-4, characterized in that, The statement that modifies the program for the (N+1)th time, and M N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 ,include: When the modified statement is an arithmetic statement and the intermediate results are in the same memory location, M will be... N As M N+1 ; When the modified statement is an operation statement, and the intermediate results are not in the same memory location, M N+1 The probability of missing tests corresponding to the test cases in the middle is 1 and M. N The difference between the missed test probabilities of the corresponding test cases; When the modified statement is a flow control statement, M will be... M As N N+1 .

6. A program testing device, characterized in that, The device includes: a first acquisition unit, a determination unit, a second acquisition unit, and a testing unit; The first acquisition unit is used to acquire the test case set M corresponding to the Nth modified program, which has a high probability of missing tests. N The test case set for the probability of missed detection includes test cases and the probability of missed detection corresponding to each test case; wherein, the step of obtaining the test case set M for the probability of missed detection corresponding to the Nth modified program is... N The process includes: when N is 0, obtaining a test case set for testing the unmodified program, estimating the probability of missed tests for each test case in the test case set, and forming a test case set with missed test probability corresponding to the unmodified program; obtaining the test case set for testing the unmodified program and estimating the probability of missed tests for each test case in the test case set includes: obtaining the test case set for testing the unmodified program; obtaining the probability of covering the incorrect statement, the probability of the incorrect intermediate state occurring, and the probability of outputting an incorrect result for each test case in the test case set; determining that the probability of missed tests for the test case is the product of the probability of covering the incorrect statement, the probability of the incorrect intermediate state occurring, and the probability of outputting an incorrect result; The determining unit is configured to determine the type of the statement that modifies the program for the (N+1)th time, and the M obtained by the first obtaining unit. N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 ; The second acquisition unit is used to acquire the M determined by the determining unit. N+1 The test cases with a missed detection probability greater than a preset threshold constitute the regression test case set; The testing unit is used to test the program after the N+1th modification using the regression test case set obtained by the second acquisition unit.

7. The apparatus according to claim 6, characterized in that, The determining unit is specifically used to determine the type of the statement that modifies the program for the (N+1)th time, and M. N Determine the set of test cases M corresponding to the missed detection probability of the program after the (N+1)th modification. N+1 This includes situations where the modified statement is an arithmetic statement and the intermediate results reside in the same memory location, in which case M will be... N As M N+1 When the modified statement is an operation statement, and the intermediate results are not in the same memory location, M N+1 The probability of missing tests corresponding to the test cases in the middle is 1 and M. N The difference between the missed test probabilities of the corresponding test cases; when the modified statement is a flow control statement, M will be... N As M N+1 .

8. An electronic 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 program, it implements the method as described in any one of claims 1-5.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method described in any one of claims 1-5.

Citation Information

Patent Citations

  • System and method for selecting test case for regression test

    CN105528293A

  • Test case screening method and device and medium

    CN111274126A