Test case determination method and system based on impact domain path analysis
By performing control process analysis of the test program and generation of path branch graphs, the problem of low manual analysis efficiency in regression tests is solved, and the minimum test case determination is achieved that meets the maximum coverage requirement is achieved, which improves the regression testing efficiency.
Patent Information
- Application Number
- CN202111430805.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-11-29
AI Technical Summary
In the prior art, manual analysis of test cases during regression testing is not efficient, and it is difficult to ensure the coverage of the test strategy.
By analyzing the syntax and control flow of the test program, the nodes of the program control flow chart are extracted, and the nodes are compressed to generate a path branch diagram. Establish a mapping relationship between the path branch graph and the first round of test case set, compare the test program and the regression test program, generate a change path branch graph, and select the minimum test case set that meets the maximum coverage indicator.
This enables rapid determination of the minimum set of test cases that can cover the affected change path branches, reduces the number of test cases used by regression tests, and improves the efficiency of regression tests.
Smart Images

Figure CN113934643B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a test case determination method and system based on impact domain path analysis. Technical Background
[0002] During the software testing process, if software defects are found in the first round of full-set testing, the software needs to be upgraded and regression tested. If software defects are still found in regression testing, regression testing needs to be iterated continuously until the software is defect-free or the software defects are within an acceptable range. During regression testing, testers usually analyze and compare the differences between different versions, select execution cases from the full set of test cases, or design new test cases. In this process, by analyzing the impact domain after each software change, only the affected function call paths can be analyzed in subsequent tests, which can save testing costs and improve efficiency. At present, this work mainly relies on manual analysis, but the efficiency of manual analysis is not high and the coverage requirements of the test strategy are difficult to guarantee. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a method and system for determining the minimum test case that meets the maximum coverage requirement based on influence domain path analysis in view of the defects in the prior art.
[0004] The technical solution adopted by the present invention to solve the technical problem is: a test case determination method based on impact domain path analysis, comprising:
[0005] Analyze the syntax and control flow of the test program and extract the nodes of the program control flow chart;
[0006] Compress the nodes of the control flow graph to generate a path branch graph;
[0007] Establish the mapping relationship between the path branch graph and the first round of test case set;
[0008] Compare the first round test program with the regression test program, generate the change module of the regression test, perform change impact domain analysis, and generate the change path branch diagram of the regression test program;
[0009] A minimum test case set that meets the maximum coverage index of the change path branch graph is selected from the test cases as the regression test case set of the current version.
[0010] Preferably, the method for extracting nodes of the program control flow chart is to merge sequentially executed statements and retain branch statements and jump statements.
[0011] Preferably, the program control flow graph is represented as a directed graph G=(N, E, S, T), wherein N is a node set of the directed graph, representing node statements in the program; E is an edge set of the directed graph, representing the control flow between nodes in the program; S is the program start node, T is the program end node,
[0012] The method for compressing the nodes of the control flow graph is:
[0013] If edge E i For node N a To N b , and N a The out-degree of Nb is 1, and the in-degree of Nb is 1, then the node N a and N b Merge into new node N ab , new node N ab The input edge is N a The input edge is N, and the output edge is b ; traverse the edges in the directed graph G until there are no directed edges in the directed graph G that meet the merging conditions.
[0014] Preferably, the mapping relationship between the path branch graph and the first round of test case set includes a one-to-many mapping between the test case and the branch nodes contained in the test case execution path, and a one-to-many mapping between the branch nodes in the path branch graph and the test cases covering the branch nodes.
[0015] Preferably, the method for generating the change path branch graph is:
[0016] The first round of full test programs and the regression test programs are compared to obtain difference codes. In the path branch graph of the regression test program, the path covering the node where any difference code is located is the change path, and the set of all change paths is the change path branch graph. The test cases of the regression test completely cover the change path branch graph.
[0017] Preferably, the method for selecting regression test cases from the first round of full test case set is a greedy algorithm or a dynamic programming algorithm.
[0018] Preferably, the coverage indicators of the modified path branch graph include statement coverage, branch coverage and control flow coverage.
[0019] Preferably, when there are multiple alternative test case sets, the alternative test case set that meets the lower limit requirement of the maximum coverage index is used as the test case set for the current regression test; when there are multiple alternative test case sets whose coverage all meets the lower limit of the maximum coverage index, the alternative test case set with the least test cases is used as the test case set for the current regression test.
[0020] Preferably, when there are no test cases that meet the lower limit requirement of the maximum coverage index, new test cases are added to the test case set with the largest coverage until its coverage is no less than the lower limit of the maximum coverage index, and the supplemented set is used as the test case set for the current regression test.
[0021] The present invention also provides a test case determination system based on impact domain path analysis, comprising:
[0022] Node extraction module: analyzes the syntax and control flow of the test program and extracts the nodes of the program control flow chart;
[0023] Path branch graph generation module: compresses the nodes of the control flow graph to generate a path branch graph;
[0024] Mapping establishment module: establishes the mapping relationship between the path branch graph and the first round of test case set;
[0025] Impact domain analysis module: compares the first round test program and the regression test program, generates the change module of the regression test, performs change impact domain analysis, and generates a change path branch diagram of the regression test program;
[0026] Test case determination module: selects the minimum test case set that meets the maximum coverage index of the change path branch graph from the test cases as the regression test case set of the current version.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] By extracting and compressing the key nodes of the program control flow chart, simplifying the path of the program processing flow, and establishing a mutual mapping relationship based on the compressed path and branch nodes, after determining the impact domain of the regression test, the branch nodes included in the affected change path branches can be quickly determined, and the minimum test case set covering the affected branch nodes can be determined based on the branch nodes, thereby reducing the number of test cases used in the regression test and improving the efficiency of the regression test. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings in the following descriptions are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work. By reading the detailed description of the non-limiting embodiments with reference to the following drawings, other features, purposes and advantages of the present invention will become more obvious:
[0030] Figure 1is a flow chart of a test case determination method based on impact domain path analysis provided by an embodiment of the present invention;
[0031] Figure 2 It is an execution logic diagram of a test case determination method based on impact domain path analysis provided by an embodiment of the present invention;
[0032] Figure 3 It is a schematic diagram of a test case determination system based on impact domain path analysis provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements may be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0034] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0036] like Figure 1 As shown, this embodiment provides a test case determination method based on impact domain path analysis, including:
[0037] Analyze the syntax and control flow of the test program and extract the nodes of the program control flow chart;
[0038] Compress the nodes of the control flow graph to generate a path branch graph;
[0039] Establish the mapping relationship between the path branch graph and the first round of test case set;
[0040] Compare the first round test program with the regression test program, generate the change module of the regression test, perform change impact domain analysis, and generate the change path branch diagram of the regression test program;
[0041] A minimum test case set that meets the maximum coverage index of the change path branch graph is selected from the test cases as the regression test case set of the current version.
[0042] This embodiment simplifies the path of the program processing flow by extracting and compressing the key nodes of the program control flow chart, and establishes a mutual mapping relationship based on the compressed path and branch nodes. After determining the impact domain of the regression test, the branch nodes included in the affected change path branches can be quickly determined, and the minimum test case set covering the affected branch nodes is determined based on the branch nodes, thereby reducing the number of test cases used in the regression test and improving the efficiency of the regression test.
[0043] Specific, combined Figure 1 and Figure 2 The test case determination method provided in this embodiment includes:
[0044] S1: Analyze the syntax and control flow of the test program and extract the nodes of the program control flow graph;
[0045] The method for extracting nodes of a program control flow chart is to merge sequential execution statements and retain branch statements and jump statements; specifically, for each program module, the sequential execution statements in the module are merged and only control flow nodes such as branch statements and jump statements are retained.
[0046] S2: compress the nodes of the control flow graph to generate a path branch graph;
[0047] The program control flow graph is represented as a directed graph G=(N, E, S, T), where N is a node set of the directed graph, representing node statements in the program; E is an edge set of the directed graph, representing the control flow between nodes in the program; S is the program start node, T is the program end node,
[0048] The method for compressing the nodes of the control flow graph is:
[0049] If edge E i For node N a To N b , and N a The out-degree of Nb is 1, and the in-degree of Nb is 1, then the node N a and N b Merge into new node N ab , new node N ab The input edge is N aThe input edge is N, and the output edge is b ; traverse the edges in the directed graph G until there are no directed edges in the directed graph G that meet the merging conditions.
[0050] S3: Establish the mapping relationship between the path branch graph and the first round of test case set;
[0051] The mapping relationship between the path branch graph and the first round of test case set includes a one-to-many mapping between the test case and the branch nodes included in the test case execution path, and a one-to-many mapping between the branch nodes in the path branch graph and the test cases covering the branch nodes. Thus, the branch nodes and test cases are mapped to each other, which facilitates the determination of the coverage relationship.
[0052] S4: Compare the first round test program and the regression test program, generate the change module of the regression test, perform change impact domain analysis, and generate a change path branch diagram of the regression test program;
[0053] Compare the first round of full test programs and the regression test programs to obtain difference codes. In the path branch graph of the regression test program, the path covering the node where any difference code is located is the change path. The set of all change paths is the change path branch graph. The test cases of the regression test completely cover the change path branch graph.
[0054] The method for selecting regression test cases from the first round of full test case collection is a greedy algorithm or a dynamic programming algorithm.
[0055] S5: Select a minimum test case set that meets the maximum coverage index of the change path branch graph from the test cases as the regression test case set for the current version.
[0056] The coverage indicators of the modified path branch graph include statement coverage, branch coverage and control flow coverage; when there are multiple alternative test case sets, the alternative test case set that meets the lower limit requirement of the maximum coverage indicator is used as the test case set for the current regression test; when there are multiple alternative test case sets whose coverage rates all meet the lower limit of the maximum coverage indicator, the alternative test case set with the least test cases is used as the test case set for the current regression test.
[0057] When there are no test cases that meet the lower limit of the maximum coverage index, new test cases are added to the test case set with the largest coverage until its coverage is no less than the lower limit of the maximum coverage index. The supplemented set is used as the test case set for the current regression test.
[0058] refer to Figure 3 This embodiment also provides a test case determination system based on impact domain path analysis, including
[0059] Node extraction module: analyzes the syntax and control flow of the test program and extracts the nodes of the program control flow chart;
[0060] Path branch graph generation module: compresses the nodes of the control flow graph to generate a path branch graph;
[0061] Mapping establishment module: establishes the mapping relationship between the path branch graph and the first round of test case set;
[0062] Impact domain analysis module: compares the first round test program and the regression test program, generates the change module of the regression test, performs change impact domain analysis, and generates a change path branch diagram of the regression test program;
[0063] Test case determination module: selects the minimum test case set that meets the maximum coverage index of the change path branch graph from the test cases as the regression test case set of the current version.
[0064] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices (systems) or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0065] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the embodiments can be referred to each other. The above description of the disclosed embodiments enables professionals and technicians in this field to implement or use the present invention. Various modifications to these embodiments will be obvious to professionals and technicians in this field, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to these embodiments shown in this article, but will comply with the widest range consistent with the principles and novel features disclosed herein.
[0066] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art may make various modifications or variations within the scope of the claims, which do not affect the essence of the present invention.
Claims
1. A test case determination method based on impact domain path analysis, characterized in that: include: Analyze the syntax and control flow of the test program and extract the nodes of the program control flow chart; Compress the nodes of the control flow graph to generate a path branch graph; Establish the mapping relationship between the path branch graph and the first round of test case set; Compare the first round test program with the regression test program, generate the change module of the regression test, perform change impact domain analysis, and generate the change path branch diagram of the regression test program; Select the minimum test case set that meets the maximum coverage index of the change path branch graph from the test cases as the regression test case set of the current version; The mapping relationship between the path branch graph and the first round of test case set includes a one-to-many mapping between a test case and a branch node included in the test case execution path, and a one-to-many mapping between a branch node in the path branch graph and a test case covering the branch node; The method for generating the change path branch graph is: The first round of full test programs and the regression test programs are compared to obtain difference codes. In the path branch graph of the regression test program, the path covering the node where any difference code is located is the change path, and the set of all change paths is the change path branch graph. The test cases of the regression test completely cover the change path branch graph.
2. The test case determination method based on impact domain path analysis according to claim 1 is characterized in that: The method for extracting nodes of the program control flow chart is to merge sequentially executed statements and retain branch statements and jump statements.
3. The test case determination method based on impact domain path analysis according to claim 2 is characterized in that: The program control flow chart is represented as a directed graph , where N is the node set of the directed graph, representing the node statements in the program; E is the edge set of the directed graph, representing the control flow between nodes in the program; S is the starting node of the program, and T is the ending node of the program. The method for compressing the nodes of the control flow graph is: If the edge For Node arrive , and The out-degree of is 1, If the in-degree is 1, then the node and Merge into new nodes , new node The input edge is The input edge is The output edge of Traverse the edges in the directed graph G until there are no directed edges in the directed graph G that meet the merging conditions.
4. The test case determination method based on impact domain path analysis according to claim 1 is characterized in that: The method for selecting regression test cases from the first round of full test case collection is a greedy algorithm or a dynamic programming algorithm.
5. The test case determination method based on impact domain path analysis according to claim 1 is characterized in that: The coverage indicators of the modified path branch graph include statement coverage, branch coverage and control flow coverage.
6. The test case determination method based on impact domain path analysis according to claim 5 is characterized in that: When there are multiple alternative test case sets, the alternative test case set that meets the lower limit of the maximum coverage index is used as the test case set for the current regression test. When there are multiple alternative test case sets whose coverage meets the lower limit of the maximum coverage index, the alternative test case set with the least test cases is used as the test case set for the current regression test.
7. The test case determination method based on impact domain path analysis according to claim 6 is characterized in that: When there are no test cases that meet the lower limit of the maximum coverage index, new test cases are added to the test case set with the largest coverage until its coverage is no less than the lower limit of the maximum coverage index. The supplemented set is used as the test case set for the current regression test.
8. A test case determination system based on impact domain path analysis, characterized in that: include: Node extraction module: analyzes the syntax and control flow of the test program and extracts the nodes of the program control flow chart; Path branch graph generation module: compresses the nodes of the control flow graph to generate a path branch graph; Mapping establishment module: establishes the mapping relationship between the path branch graph and the first round of test case sets; Impact domain analysis module: compares the first round test program and the regression test program, generates the change module of the regression test, performs change impact domain analysis, and generates a change path branch diagram of the regression test program; Test case determination module: selects the minimum test case set that meets the maximum coverage index of the change path branch graph from the test cases as the regression test case set of the current version; The mapping relationship between the path branch graph and the first round of test case set includes a one-to-many mapping between a test case and a branch node included in the test case execution path, and a one-to-many mapping between a branch node in the path branch graph and a test case covering the branch node; The method for generating the change path branch graph is: The first round of full test programs and the regression test programs are compared to obtain difference codes. In the path branch graph of the regression test program, the path covering the node where any difference code is located is the change path, and the set of all change paths is the change path branch graph. The test cases of the regression test completely cover the change path branch graph.
Citation Information
Patent Citations
Software test case automatic generating method and system
CN101436128A
Threading test method and device, computer device and storage medium
CN109783387A