A test case priority ordering method and system based on test heterogeneous graphs
By constructing a heterogeneous test graph and evaluating node centrality, the problems of insufficient information utilization and high computational cost in existing technologies are solved, achieving efficient and accurate test case sorting and improving defect discovery efficiency.
Patent Information
- Application Number
- CN202511373796.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-09-25
AI Technical Summary
Existing test case prioritization methods cannot systematically model the complex relationship between test cases and the internal structure of the program. They lack information utilization, lack systematic modeling of complex relationships, rely on historical data, and consume high computational resources, making it difficult to meet the needs of large-scale software systems for efficient and accurate test case prioritization.
A test heterogeneity graph-based approach is adopted. By constructing a test heterogeneity graph, the static code structure and coverage relationships of the program are integrated. The centrality of nodes is measured by global topology to evaluate the relative importance of test cases and prioritize them.
It achieves unified modeling of test cases and code structure information, improves the accuracy of test case priority ranking and defect detection rate, reduces computational costs, is suitable for large-scale program analysis tasks, and has strong adaptability and application value.
Smart Images

Figure CN120872847B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of software testing technology, and in particular relates to a test case priority ranking method and system based on test heterogeneity graphs. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] Existing test case prioritization methods largely rely on coverage or historical execution information, typically represented only by binary relation matrices (such as coverage matrices). This approach fails to systematically model the complex relationships between test cases and the program's internal structure. For example, a coverage matrix struggles to express the relationship between "test cases" and "test cases." The statement was executed. → Statement It is a statement Preconditions for execution → Statement Test Case The current methods rely on a single, linear chain of execution, failing to capture higher-order interactions and resulting in inconsistent defect detection rates. While sorting test cases based on their historical execution results (e.g., defect detection rates) is feasible, this requires extensive high-quality historical data, limiting its applicability and consuming significant computational resources. Furthermore, existing methods often separate test behavior analysis from code structure analysis, hindering information integration and failing to comprehensively reflect dynamic changes in program behavior. This ultimately leads to insufficient utilization of test information, impacting the effectiveness of the sorting results and the efficiency of defect discovery. In summary, current technologies generally suffer from insufficient information utilization, a lack of system modeling for complex relationships, strong reliance on historical data, and high computational costs, making it difficult to meet the demands for efficient and accurate test case sorting in large-scale software systems. Summary of the Invention
[0004] To address at least one of the technical problems mentioned above, this invention provides a test case priority ranking method and system based on test heterogeneous graphs. This method effectively integrates and characterizes key information generated during software testing, can efficiently adapt to large-scale program analysis tasks, and does not rely on GPU resources.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] A first aspect of the present invention provides a test case priority ranking method based on a test heterogeneity graph, comprising the following steps:
[0007] Analyzing a given program under test, constructing a static code structure representation of the program based on the result of the analysis, executing a test suite on the program under test based on the static code structure representation of the program, introducing a coverage relationship, and generating a test heterogeneous graph;
[0008] Based on the constructed test heterogeneous graph, constructing a transition matrix;
[0009] Based on the constructed transition matrix, analyzing the link structure of the nodes, using global topology to measure the centrality of each element, evaluating the relative importance score of the test cases, prioritizing the test cases according to the relative importance score of the test cases, and obtaining the test case priority ranking result.
[0010] Further, the construction of the static code structure representation of the program based on the result of the analysis specifically includes: constructing method nodes and statement nodes, adding structure edges between method nodes and statement nodes, and adding call edges between method nodes, thereby forming the static code structure representation of the program.
[0011] Further, the generated test heterogeneous graph is represented as , wherein represents a set of nodes, including method nodes , statement nodes and test nodes to represent various elements involved in the test process; represents a set of edges, used to describe the relationship between different nodes, including structure edges representing the code structure relationship between methods and statements , call edges representing the function call relationship between methods and coverage edges representing the coverage relationship between statements and test cases.
[0012] Further, the formal description of the test heterogeneous graph includes intra-function code structure representation, inter-function code structure representation and coverage representation;
[0013] Intra-function code structure representation: given a method m and its contained statements s , their relationship is represented as a structure edge , wherein and represent statement nodes and method nodes respectively;
[0014] Inter-function code structure representation: given two methods m 1 and m 2, if method m 1 is called by m 2, the call relationship is represented as , wherein and are the corresponding nodes of the methods m 1 and m 2 respectively;
[0015] Coverage representation: the node set corresponding to all test cases in a given test suite T , denotes T the node set corresponding to all test cases in a given test suite; if a test case t executes to a statement s , it is represented as a coverage edge , where , , .
[0016] Further, based on the constructed test heterogeneous graph, a transition matrix is constructed, comprising:
[0017] calculating the transition probability matrix between nodes, which includes bidirectional transition matrix between methods, bidirectional transition matrix between methods and statements, and bidirectional transition matrix between statements and test cases;
[0018] The transition matrix is constructed by combining the bidirectional transition matrix between methods, the bidirectional transition matrix between methods and statements, and the bidirectional transition matrix between statements and test cases.
[0019] Further, based on the constructed transition matrix, the link structure of the nodes is analyzed, the centrality of each element is measured by global topology, and the relative importance score of the test cases is evaluated, comprising:
[0020] Based on the transition matrix, the structural centrality value of the node in the information interaction process is calculated by the transitivity of the link relationship through an iterative calculation method; ;
[0021] According to the structural centrality value of the node in the information interaction process, the structural centrality value of the test case and the structural centrality value of the statement node are determined ; According to the structural centrality value of the test case and the structural centrality value of the statement node ,
[0022] the comprehensive score of the test case is calculated by weighting. Further, when calculating the structural centrality value of the node in the information interaction process, the structural centrality values of all nodes in the graph are calculated
[0023] . Combined, they can be viewed as a single feature vector. Assuming to use n To represent using a dimensional vector 𝑥 n The PR value of each node, In the K The following eigenvalue equations should be satisfied in the next iteration:
[0024] ,
[0025] in, express In the K The eigenvalues of the next iteration It means that 𝑥 is in the first K The eigenvalues of the -1st iteration, the first term This indicates that weights are passed between nodes through the edges of the graph; the second term... This indicates that each iteration jumps back to the initially focused set of nodes. The 𝑛-dimensional random jump directional 𝑣 determines the injection point of the information flow. This represents the damping coefficient.
[0026] Furthermore, the overall score for the test cases is expressed as follows:
[0027] ,
[0028] ,
[0029] ,
[0030] ,
[0031] Where α∈[0,1] represents the relative weight of the control test case's self-centrality and the contribution of the coverage statement. This represents the centrality score of the test case itself. Represents each test node In testing the structure centrality value of heterogeneous graphs The centrality-weighted backpropagation of statement nodes is used to obtain the statement contribution score when it is passed to the test cases. These are the weighting coefficients. The set of statements covered for each test case. Represents each statement node The structural centrality value is tested in the heterogeneous graph.
[0032] A second aspect of the present invention provides a test case priority ranking system based on a test heterogeneous graph, comprising:
[0033] The test heterogeneous graph construction module is used for parsing a given test program, constructing a static code structure representation of the program based on the parsed result, executing a test suite on the test program based on the static code structure representation of the program, introducing a coverage relationship, and generating a test heterogeneous graph;
[0034] The transition matrix construction module is used for constructing a transition matrix based on the constructed test heterogeneous graph.
[0035] The test case priority ranking module is used for analyzing the link structure of the nodes, evaluating the relative importance scores of the test cases by using global topology metrics to measure the centrality of each element, and performing priority ranking according to the relative importance scores of the test cases to obtain a test case priority ranking result.
[0036] The third aspect of the present application provides a computer readable storage medium.
[0037] A computer readable storage medium has a computer program stored thereon, and the program is executed by a processor to implement the steps of the test case priority ranking method based on a test heterogeneous graph.
[0038] The fourth aspect of the present application provides a computer device.
[0039] A computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the program to implement the steps of the test case priority ranking method based on a test heterogeneous graph.
[0040] Compared with the prior art, the present application has the following beneficial effects:
[0041] 1. The present application breaks the information island based on the global information representation capability of the test heterogeneous graph, and constructs a test heterogeneous graph by introducing the idea of graph representation, so as to represent the program entities and test cases and the diversified relationships between the elements in the software testing process by using the graph node and edge structure. This representation method realizes the unified representation of the three types of entities of "method-statement-test case", effectively integrates and represents the key information generated in the software testing process.
[0042] 2. The present application adopts a lightweight test case comprehensive evaluation method, uses the topological relationship between nodes, combines semantic information, adaptively evaluates the centrality of each node, comprehensively quantifies the importance of test cases in the entire graph, and alleviates the local bias caused by incomplete information or excessive dependence on local relationships. This evaluation method does not require training data, has low computational cost, can efficiently adapt to large-scale program analysis tasks, and does not depend on GPU resources.
[0043] 3、The application effectively improves the precision of test case priority sorting and the defect detection rate under the premise of ensuring low computing overhead. At the same time, due to the universality of the modeling mode of the test heterogeneous graph, the test heterogeneous graph can be naturally extended to multiple downstream tasks such as error positioning, test redundancy detection and test optimization, and has strong adaptability and application value.
[0044] Advantages of the additional aspects of the application will be partially given in the following description, partially will become obvious from the following description, or will be understood by the practice of the application. BRIEF DESCRIPTION OF DRAWINGS
[0045] The drawings accompanying the specification of this application form a part thereof, serve to further illustrate the illustrative embodiments of the application and to explain the principles of the application, and are not intended to limit the application.
[0046] Figure 1 is a test case priority sorting method flowchart based on a test heterogeneous graph provided by an embodiment of the application;
[0047] Figure 2 is a test heterogeneous graph constructed by an embodiment of the application;
[0048] Figure 3 is a transition matrix constructed by an embodiment of the application;
[0049] Figure 4 is a test case priority sorting system block diagram based on a test heterogeneous graph provided by an embodiment of the application. DETAILED DESCRIPTION
[0050] The application will be further described below in conjunction with the drawings and embodiments.
[0051] It should be noted that the following detailed description is all exemplary, and is intended to provide further explanation of the application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as generally understood by those skilled in the art to which the application belongs.
[0052] It should be noted that the terms used herein are only for the purpose of describing specific embodiments, and are not intended to limit the exemplary embodiments according to the application. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form, and in addition, it should be understood that when the terms "comprise" and / or "include" are used in the specification, they indicate the presence of a feature, step, operation, device, component and / or combination thereof.
[0053] With the increasing size and complexity of software, software testing has become an important link to ensure software quality and reliability. Among them, the test case priority ranking technology as a key means to improve test efficiency and shorten test cycle has received widespread attention in recent years. Existing test optimization and priority ranking methods mainly include: (1) coverage-based method: determine the priority of test cases by statistical coverage of test cases on code based on coverage matrix, but the information utilization is single, and the defect detection rate is often unstable; (2) machine learning-based method: use deep learning, reinforcement learning and other technologies to rank test cases according to their execution results (such as defect detection) in historical versions, but this method requires a large amount of high-quality historical data, has limited applicability, and consumes high computing resources; (3) dependency-based method: try to incorporate internal program dependencies into modeling, but most of them are limited to static dependency analysis, lacking comprehensive modeling of dynamic behavior.
[0054] In summary, the existing technologies generally have the problems of insufficient information utilization, lack of systematic modeling of complex relationships, strong dependence on historical data, and high computational cost, which makes it difficult to meet the needs of efficient and accurate test case ranking in large-scale software systems. These deficiencies are the starting point for the new method proposed in this invention.
[0055] The present invention provides a test case priority ranking method based on test heterogeneous graph. This method can be divided into two stages: (1) test heterogeneous graph representation and construction. Through the data representation form of the test heterogeneous graph, the diversified relationship between the program entities (such as methods, statements) and the test cases is comprehensively preserved, thereby realizing the unified modeling of the test behavior and the code structure information, and ensuring the completeness of information representation and analysis. (2) lightweight test case importance evaluation. Based on the topological connection relationship and semantic information of the nodes in the graph, a lightweight algorithm is used to evaluate the importance of the test cases as a whole, so that high-value test cases can be executed first, thereby improving the defect detection rate and test efficiency.
[0056] Embodiment one
[0057] As shown in Figure 1 The present embodiment provides a test case priority ranking method based on test heterogeneous graph, which includes the following steps:
[0058] Step 1: parse the given program to be tested, and construct a static code structure representation of the program based on the parsed results. Based on the static code structure representation of the program, execute the test suite on the program to be tested, introduce the coverage relationship, and generate the test heterogeneous graph.
[0059] In the construction of the test heterogeneous graph, the core is to use different types of edges to represent the code structure relationship and the coverage relationship respectively, so as to keep the multiple information involved in the test process of the program as a whole and uniformly in the form of a graph. In this way, not only the static structure and dynamic behavior of the program can be represented simultaneously and uniformly, but also the direct association and high-order interaction relationship between program elements can be effectively modeled, providing complete information support for subsequent global analysis and priority sorting.
[0060] Specifically includes the following steps:
[0061] Step 101, parsing the given program under test, and constructing the static code structure representation of the program based on the parsed results;
[0062] In this embodiment, when parsing the given program under test, the Javalang toolkit can be used to parse the program , and the parsed results include each method and the statement set contained therein, and the calling relationship between the methods is identified.
[0063] Based on the parsed results, the static code structure representation of the program is constructed, specifically including: constructing method nodes and statement nodes, adding structure edges between the method nodes and the statement nodes, and adding calling edges between the method nodes, so as to form the static code structure representation of the program.
[0064] Step 102, based on the static code structure representation of the program, executing the test suite on the program under test, introducing the coverage relationship, and generating the test heterogeneous graph;
[0065] On the program , the test suite is executed, wherein each test case is numbered , and n denotes the test case numbered , and denotes a test case in T.
[0066]
[0067] It should be particularly noted that this step needs to mark the test results of the test cases.
[0068] Finally, for the given program under test and the corresponding test suite , the corresponding test heterogeneous graph can be represented as , wherein denotes a node set including method nodes , statement nodes and test nodes to represent various elements involved in the testing process; representing edge sets to describe the relationships between different nodes, including structure edges representing the code structure relationship between methods and statements , call edges representing the function call relationship between methods and coverage edges representing the coverage relationship between statements and test cases ;
[0069] The formal description of the test heterogeneous graph is as follows:
[0070] Intra-function code structure representation: given a method m and its contained statements s , their relationship can be represented as a structure edge , where and represent the statement node and the method node respectively;
[0071] Inter-function code structure representation: given two methods m 1 and m 2, if method m 1 is called by m 2, their call relationship can be represented as , where and are the corresponding node representations of methods m 1 and m 2 respectively.
[0072] Coverage representation: given a test suite T , refers to the node set corresponding to all test cases in T . If a test case t executes to statement s , it can be represented as a coverage edge , where , , .
[0073] Through the data representation form of the test heterogeneous graph, the diversified relationships between program entities (such as methods and statements) and test cases are comprehensively preserved, thereby realizing the unified modeling of test behavior and code structure information and ensuring the completeness of information representation and analysis.
[0074] Step 2: Based on the constructed test heterogeneous graph, construct the transition matrix;
[0075] Each element in the test heterogeneous graph is related to each other by multi-type edges and carries context information. To this end, this stage estimates the centrality of each element by analyzing the node link structure and using global topology metrics to more accurately assess the relative importance of test cases. Considering the size of the graph and the cost of computation, this stage adopts a lightweight PageRank method for centrality estimation;
[0076] Specifically includes the following steps:
[0077] Step 201, calculate the transition probability matrix between nodes, the transition probability matrix between nodes includes the bidirectional transition matrix between methods and methods, the bidirectional transition matrix between methods and statements, and the bidirectional transition matrix between statements and test cases;
[0078] In this embodiment, for each node pair , the transition probability on a certain relationship depends on the out-degree of the node on the corresponding edge type , and the specific calculation formula is as follows:
[0079] ,
[0080] The test heterogeneous graph stores the link relationship of the graph in the form of an adjacency matrix, and the order of the row / column nodes is all methods M, all statements S, and all test cases T.
[0081] As shown in Figure 2 , a test heterogeneous graph is constructed, and the construction process of the transition matrix is described taking the test heterogeneous graph as an example, wherein and are method nodes, , and are statement nodes, and are test case nodes; taking the first node as an example, the node is a method node, and it is assumed that it only has a calling relationship with the second method , so the probability of jumping to the second node is 1, and therefore . is a transition matrix constructed in this way using method calling edges. The construction principles of other matrices are the same, except that the edge types are different.
[0082] Finally, based on the calculation rules of the transition probability matrix between nodes, the bidirectional transition matrix between methods and statements derived based on structural edges and , the bidirectional transition matrix between methods and methods established by calling edges and The bidirectional transition matrix between the statement of the coverage edge and the test case And As shown in the figure, the green part is the calculated bidirectional transition matrix between methods, the blue part is the calculated bidirectional transition matrix between methods and statements, and the yellow part is the bidirectional transition matrix between the statement of the coverage edge and the test case. Figure 3
[0083] Step 202, combine the bidirectional transition matrix between methods, the bidirectional transition matrix between methods and statements, and the bidirectional transition matrix between the statement and the test case to construct a transition matrix;
[0084] Assuming that the graph is stored in the form of a matrix, the order of the row / column nodes is all methods M, all statements S, and all test cases T, the calling relationship between methods and methods is stored to the first row and the first column of the transition matrix, and the finally constructed transition matrix is represented as:
[0085] ,
[0086] The present application uses a lightweight algorithm (PageRank) to evaluate the importance of test cases as a whole based on the topological connection relationship and semantic information of the nodes in the graph, so that high-value test cases can be executed preferentially, thereby improving the defect detection rate and test efficiency.
[0087] Step 3: Based on the constructed transition matrix, analyze the link structure of the nodes, use global topology to measure the centrality of each element, evaluate the relative importance score of the test cases, and prioritize according to the relative importance score of the test cases to obtain the test case priority ranking result;
[0088] Step 301, based on the transition matrix, by the transitivity of the link relationship, using iterative calculation method, calculate its node Structural centrality in the process of information interaction , the structural centrality values of all nodes in the graph are taken together as a feature vector ;
[0089] The basic principle is: the node linked by an important node should be more important than the node linked by an unimportant node. Specifically, the PR value of a node depends on the PR value of the node pointing to it. Assuming that an dimensional vector is used to represent the PR value of n nodes, in the first K iteration should satisfy the following eigenvalue equation:
[0090] ,
[0091] where the first term represents the "passing weight" between nodes through the edges of the graph, and the second term represents the probability of "jumping back" to the initial set of nodes of interest at each iteration, so the n-dimensional random jump vector v determines the injection point of the information flow, represents the damping coefficient, in general, the test case result feedback of the current version is crucial to the test case priority ranking of the next version. Test failures reflect software defects, which may affect the stability and performance of the next version.
[0092] Therefore, the embodiment is biased to retain failed tests to ensure continued verification in subsequent versions. To this end, these nodes are assigned higher initial weights in the n-dimensional random jump vector v, and the initial value of the vector x is set to the vector v, thereby fully utilizing the semantic information of the test cases. In addition, the damping coefficient δ is usually set to 0.85. In this way, the sensitivity of the PageRank result to failed test cases can be effectively enhanced while maintaining the global topology evaluation, thereby improving the guidance of test case priority ranking to defect discovery.
[0093] In order to prevent isolated nodes in the graph, isolated nodes have no link relationship, which leads to the node v being inaccessible and unable to participate in the calculation. Therefore, a random jump factor is set for each node :
[0094] ,
[0095] wherein represents a fixed parameter, if is greater than 0.5, because failed tests are more likely to find defects in the next test than passed tests, so the weight of failed tests should be higher. To this end, is set to be greater than 0.5 and less than 1, represents the node set of all failed test cases, represents the node set of all passed tests, represents the node set of all test cases; When the iterative process is used to calculate the node
[0096] structural centrality value in the process of information interaction , at this time the structural centrality value of the test case and the structural centrality value of the statement node can be determined ;
[0097] Step 302, respectively calculate the test case self centrality score and the statement node centrality contribution back score, combine the test case self centrality score and the statement node centrality contribution back score to calculate the test case comprehensive score;
[0098] The effectiveness of the test case is closely related to the statement coverage and the structural importance. The statement coverage is the basis, but it is not enough to pursue to cover every line of code. More importantly, it is necessary to identify which lines of code and structures are worth testing, which is the role of "structural importance". The value of a test case often depends on whether it covers the high structural importance, such as complex branches, exception handling and core algorithms.
[0099] According to step 102, the constructed heterogeneous test graph includes method nodes , statement nodes and test nodes , represents a statement node, refers to a test case node, represents a method node; in this embodiment, the test case self centrality score and the statement node centrality contribution back score are calculated respectively, because the granularity of the statement node is finer, which can improve the accuracy of the requirements of the test case sorting.
[0100] Step 3021, calculate the test case self centrality score:
[0101] For each test node , the structural centrality value in the test heterogeneous graph is directly used as the basic score . The higher the position of the test case itself in the global topology, the higher the basic score, and the calculation formula is represented as: ;
[0102] Step 3022, calculate the statement node centrality contribution back score;
[0103] Let the statement set covered by each test case be denoted as . The corresponding each statement node s of the statement also has its structural centrality value . In order to consider the importance of the code covered by the test case, the centrality of the statement node is weighted back to the test case to obtain the statement contribution score , which is represented as:
[0104] ,
[0105] wherein, is a weight coefficient, which can be evenly divided, and is represented as ;
[0106] Step 3023, combine the test case self centrality score and the statement node centrality contribution to return the weighted calculation to obtain the test case comprehensive score, represented as:
[0107] ,
[0108] Wherein, alpha represents the relative weight of controlling the test case self centrality and the coverage statement contribution.
[0109] The application utilizes the topological relationship between nodes, combines semantic information, adaptively evaluates the centrality of each node, comprehensively quantifies the importance of the test case in the entire graph, and alleviates the local deviation caused by incomplete information or excessive dependence on local relationship. The evaluation method does not require training data, has low calculation cost, can efficiently adapt to large-scale program analysis tasks, and does not depend on GPU resources.
[0110] Embodiment two
[0111] As shown in Figure 4 , the embodiment provides a test case priority ranking system based on a test heterogeneous graph, which comprises:
[0112] A test heterogeneous graph construction module is configured to parse a given program under test, construct a static code structure representation of the program based on the parsed results, execute a test suite on the program under test based on the static code structure representation, introduce a coverage relationship, and generate a test heterogeneous graph.
[0113] A transition matrix construction module is configured to construct a transition matrix based on the constructed test heterogeneous graph.
[0114] A test case priority ranking module is configured to analyze the link structure of the nodes based on the constructed transition matrix, measure the centrality of each element using global topology, evaluate the relative importance score of the test cases, perform priority ranking according to the relative importance score of the test cases, and obtain the test case priority ranking result.
[0115] It should be noted that the specific implementation of the test case priority ranking system based on the test heterogeneous graph of the embodiment of the application is similar to the specific implementation of the test case priority ranking method based on the test heterogeneous graph of the embodiment of the application. For details, please refer to the description in the method part. In order to reduce redundancy, this part will not be repeated here.
[0116] Embodiment three
[0117] The embodiment provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement steps of a test case priority sorting method based on a test heterogeneous graph.
[0118] Embodiment four
[0119] The embodiment provides a computer device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements steps of a test case priority sorting method based on a test heterogeneous graph when executing the program.
[0120] Embodiment five
[0121] The embodiment provides a program product, which is a computer program product, comprising a computer program, and the computer program is executed by a processor to implement steps of a test case priority sorting method based on a test heterogeneous graph.
[0122] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can be in the form of a hardware embodiment, a software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer usable program code.
[0123] The present application is described with reference to flowcharts and / or block diagrams of the method, device (system) and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the computer or other programmable data processing device produce a device for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The function specified in one flow or multiple flows and / or blocks Figure 1 The device for implementing the function specified in one block or multiple blocks.
[0124] These computer program instructions can also be stored in a computer readable storage medium, which can guide the computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer readable storage medium produce a product including instruction devices, which implement the functions specified in the flowcharts and / or block diagrams. Figure 1 The function specified in one flow or multiple flows and / or blocks Figure 1the function specified in the one or more blocks.
[0125] These computer program instructions can also be loaded into a computer or other programmable data processing devices, so that a series of operational steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide operational steps for implementing the processes in the flowcharts Figure 1 the flowcharts or multiple flowcharts and / or blocks Figure 1 the steps of the function specified in the one or more blocks.
[0126] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by computer programs instructing relevant hardware, and the programs can be stored in a computer-readable storage medium. When the programs are executed, the processes of the above-mentioned embodiment methods can be included. The storage medium can be a magnetic disc, an optical disc, a read-only memory (ROM) or a random access memory (RAM), etc.
[0127] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A test case priority ranking method based on test heterogeneity graphs, characterized in that, Includes the following steps: The given program under test is parsed, and a static code structure representation of the program is constructed based on the parsing results. Based on the static code structure representation of the program, a test suite is executed on the program under test, coverage relationships are introduced, and a test heterogeneity graph is generated. The generated test heterogeneous graph is represented as follows ,in Represents a collection of nodes, including method nodes. Statement nodes and test nodes , to represent the multiple elements involved in the testing process; This represents a set of edges used to describe the relationships between different nodes, including structural edges representing the code structure relationships between methods and statements. Call edges represent the function call relationships between methods. And coverage edges that represent the coverage relationship between statements and test cases. ; Based on the constructed test heterogeneous graph, a transition matrix is built; Based on the constructed transition matrix, the link structure of the nodes is analyzed, the centrality of each element is measured using a global topology, the relative importance score of the test cases is evaluated, and the test cases are prioritized according to their relative importance scores to obtain the test case priority ranking results. Based on the constructed transition matrix, the link structure of nodes is analyzed, and the centrality of each element is measured using a global topology metric to evaluate the relative importance score of test cases, including: Based on the transition matrix, and leveraging the transitivity of link relationships, an iterative calculation method is used to compute the nodes. Structural centrality in the information exchange process value; According to the node Structural centrality in the information exchange process Values determine the structural centrality of test cases. Structural centrality values of value and statement node value; Based on the structural centrality of the test cases Structural centrality values of value and statement node The overall score of the test cases is obtained by weighting the values. node Structural centrality in the information exchange process When calculating the value, the structural centrality of all nodes in the graph is considered. Combined, they can be viewed as a single feature vector. Assuming to use n dimensional vector to indicate n The PR value of each node, In the K The following eigenvalue equations should be satisfied in the next iteration: , in, express In the K The eigenvalues of the next iteration express In the K The eigenvalues of the -1st iteration, the first term This indicates that weights are passed between nodes through the edges of the graph; the second term... This indicates that each iteration jumps back to the initially focused set of nodes. n Dimensional random jump pivot v This determines the injection point of the information flow. This represents the damping coefficient.
2. The test case priority ranking method based on test heterogeneous graphs as described in claim 1, characterized in that, The process of constructing the static code structure representation of the program based on the parsed results specifically includes: constructing method nodes and statement nodes, adding structural edges between method nodes and statement nodes, and adding call edges between method nodes, thereby forming the static code structure representation of the program.
3. The test case priority ranking method based on test heterogeneous graphs as described in claim 1, characterized in that, The formal descriptions of the heterogeneous graphs include intra-function code structure representation, inter-function code structure representation, and covering representation. Function code structure representation: Given a method m and its contained statements s Its membership is represented as a structural edge. ,in and These represent statement nodes and method nodes, respectively. Code structure representation between functions: Given two methods m 1 and m 2. If the method m 1 m 2. Calls, and their call relationships are represented as follows: ,in and These are methods m 1 and m The corresponding node representation of 2; Coverage means: given a test suite T , Reference T The set of nodes corresponding to all test cases in the set; if a test case t Execution to statement s , represented as a covering edge ,in , , .
4. The test case priority ranking method based on test heterogeneous graphs as described in claim 1, characterized in that, The construction of the transition matrix based on the constructed test heterogeneous graph includes: Calculate the transition probability matrix between each node. The transition probability matrix between each node includes the bidirectional transition matrix between methods, the bidirectional transition matrix between methods and statements, and the bidirectional transition matrix between statements and test cases. The transition matrix is constructed by combining the bidirectional transition matrices between methods, between methods and statements, and between statements and test cases.
5. The test case priority ranking method based on test heterogeneous graphs as described in claim 1, characterized in that, The overall score of the test cases is expressed as follows: , , , , Where α∈[0,1] represents the relative weight of the control test case's self-centrality and the contribution of the coverage statement. This represents the centrality score of the test case itself. Represents each test node In testing the structure centrality value of heterogeneous graphs The centrality-weighted backpropagation of statement nodes is used to obtain the statement contribution score when it is passed to the test cases. These are the weighting coefficients. The set of statements covered for each test case. Represents each statement node The structural centrality value is tested in the heterogeneous graph.
6. A test case priority ranking system based on test heterogeneity graphs, characterized in that, include: The test heterogeneity graph construction module is used to parse a given program under test, construct a static code structure representation of the program based on the parsed results, execute a test suite on the program under test based on the static code structure representation of the program, introduce coverage relationships, and generate a test heterogeneity graph. The generated test heterogeneous graph is represented as follows ,in Represents a collection of nodes, including method nodes. Statement nodes and test nodes , to represent the multiple elements involved in the testing process; This represents a set of edges used to describe the relationships between different nodes, including structural edges representing the code structure relationships between methods and statements. Call edges represent the function call relationships between methods. And coverage edges that represent the coverage relationship between statements and test cases. ; The transition matrix construction module is used to construct transition matrices based on the constructed test heterogeneous graph; The test case priority ranking module is used to analyze the link structure of nodes based on the constructed transition matrix, use the global topological metric of the centrality of each element to evaluate the relative importance score of test cases, and rank the test cases according to their relative importance scores to obtain the test case priority ranking result. Based on the constructed transition matrix, the link structure of nodes is analyzed, and the centrality of each element is measured using a global topology metric to evaluate the relative importance score of test cases, including: Based on the transition matrix, and leveraging the transitivity of link relationships, an iterative calculation method is used to compute the nodes. Structural centrality in the information exchange process value; According to the node Structural centrality in the information exchange process Values determine the structural centrality of test cases. Structural centrality values of value and statement node value; Based on the structural centrality of the test cases Structural centrality values of value and statement node The overall score of the test cases is obtained by weighting the values. node Structural centrality in the information exchange process When calculating the value, the structural centrality of all nodes in the graph is considered. Combined, they can be viewed as a single feature vector. Assuming to use n dimensional vector to indicate n The PR value of each node, In the K The following eigenvalue equations should be satisfied in the next iteration: , in, express In the K The eigenvalues of the next iteration express In the K The eigenvalues of the -1st iteration, the first term This indicates that weights are passed between nodes through the edges of the graph; the second term... This indicates that each iteration jumps back to the initially focused set of nodes. n Dimensional random jump pivot v This determines the injection point of the information flow. This represents the damping coefficient.
7. 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 program, it implements the steps in the test case priority ranking method based on test heterogeneous graphs as described in any one of claims 1-5.
Citation Information
Patent Citations
Graph-based regression test case priority ranking method
CN110502447A
Test generation and defect prediction method and system based on heterogeneous program diagram
CN120670296A