Test case sorting method and device, equipment and medium
By building a class-level multi-layer software network and evaluating the importance of testing, the problem of ignoring the importance of class and defect probability in the existing technology is solved, the accuracy and efficiency of test case sorting is improved, and the software quality and the work efficiency of the development team are improved.
Patent Information
- Application Number
- CN202411909380.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-28
AI Technical Summary
The existing test case sorting methods ignore the different importance of classes in the software and their different influence on the software, as well as the different probability of defect introduction of classes of different complexities, resulting in low accuracy of test case sorting results, high efficiency of detection errors, and reduced work efficiency of the development team.
By extracting the interactive relationship between classes and classes in the software source code, a class-level multi-layer software network is built, the importance and defect tendency of class nodes are calculated, the importance of tests of classes is evaluated, and the test cases are sorted based on the coverage information of the test cases to improve the accuracy of sorting results.
It improves the accuracy of test case sorting results, reduces the efficiency of test cases to detect errors, improves the work efficiency of the development team, and significantly improves the quality and stability of the software.
Smart Images

Figure CN119718953A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development, and in particular to a test case sorting method, device, equipment and medium. Background Art
[0002] In modern software development, software quality and performance have become important factors in corporate competitiveness. With the increasing complexity and functionality of software systems, the number of test cases has also shown a rapid growth trend. Traditional test case management methods face the challenge of how to effectively manage and optimize these test cases. The order of test cases not only affects the efficiency and coverage of the test, but may also be directly related to the reliability and stability of the software. Therefore, developing an effective test case ordering method can significantly improve the efficiency and quality of the test, and has become an important requirement in current software development.
[0003] Test case prioritization refers to placing the highest priority test cases at the earliest possible position according to the test case priorities in order to achieve certain specific goals, such as providing test feedback information as early as possible, detecting errors as early as possible, etc. The value of test case prioritization cannot be ignored. First, it can optimize the allocation of test resources to ensure that test coverage can be maximized within a limited time and budget. Second, through reasonable prioritization, high-priority defects can be quickly discovered and fixed, thereby preventing potential system crashes and security vulnerabilities in advance. In addition, effective prioritization can significantly improve the work efficiency of the development team and reduce duplication of work and waste.
[0004] At present, there are many works on test case sorting, which roughly include code-based test case sorting technology, model-based test case sorting technology, and requirement-based test case sorting technology. Code-based test case sorting technology is the current mainstream technology. This type of technology mainly uses the information contained in the program code and the test case itself to define the priority of the test case and then implement the sorting.
[0005] Although the existing work has made some progress, there are still the following problems:
[0006] (1) Existing work ignores the fact that the classes covered by test cases have different importance.
[0007] Existing works mainly sort test cases based on the number of classes covered by the test cases, which regards classes in the system as having equal status. This approach ignores the different importance of classes in the software and their different influences on the software.
[0008] (2) Existing work ignores the fact that classes of different complexity have different probabilities of introducing defects.
[0009] Different classes have different complexities and different probabilities of introducing defects. Existing works do not consider the fact that classes covered by test cases have different defect probabilities and treat all classes equally.
[0010] It can be seen that the traditional test case sorting method ignores the different importance of classes in the software and the different probabilities of introducing defects by classes of different complexity, resulting in low accuracy of test case sorting results, which further leads to high efficiency of test case error detection and greatly reduces the work efficiency of the development team. Summary of the invention
[0011] The purpose of the present application is to provide a test case sorting method, device, equipment and medium to solve the problem that the low accuracy of test case sorting results leads to high efficiency of test case error detection and low work efficiency of the development team.
[0012] To achieve the above objectives, this application provides the following solutions:
[0013] In a first aspect, the present application provides a test case sorting method, comprising:
[0014] Extract classes and the interaction between classes in the software source code, and abstract the interaction into a class-level multi-layer software network; the interaction includes inheritance between classes, any method in a class throws an exception with another class as the type, the implementation relationship between a class and an abstract class, any method in a class uses an object of another class as a parameter, a class contains an attribute, and the attribute has another class as the data type, there is a calling relationship between methods of two classes, a method in a class accesses an attribute with another class as the data type, an object of another class is instantiated in a class, any method in a class contains an object with another class as the data type, and any method in a class uses another class as the return value type;
[0015] Aggregating the class-level multi-layer software network to construct an aggregated class-level software network;
[0016] Based on the aggregated class-level software network, constructing a metric to measure class importance;
[0017] Calculating the importance of all class nodes in the aggregated class-level software network according to the metric class importance index;
[0018] Through static analysis of the software source code, the methods, attributes, and interactions between methods and methods, as well as between methods and attributes within each class are extracted, and a feature dependency network within each class is constructed;
[0019] Determine the defect tendency of each class according to the feature dependency network within each class; the defect tendency is the probability of introducing defects into each class;
[0020] Evaluate the test importance of a class based on the importance of all class nodes and the probability of all classes introducing defects;
[0021] According to the test importance of the class and the coverage information of each test case on the class, the priority of the test case for the class is evaluated, and the test cases are arranged according to the priority to generate a test case sequence; the coverage information is the set of classes covered by the test case; the priority of the test case is the sum of the test importance of all classes covered by the test case.
[0022] In a second aspect, the present application provides a test case sorting device, comprising:
[0023] A class-level multi-layer software network construction module is used to extract classes and the interaction relationships between classes in the software source code, and abstract the interaction relationships into a class-level multi-layer software network; the interaction relationships include inheritance relationships between classes, any method in a class throws an exception with another class as the type, an implementation relationship between a class and an abstract class, any method in a class uses an object of another class as a parameter, a class contains an attribute, and the attribute has another class as the data type, there is a calling relationship between methods of two classes, a method in a class accesses an attribute with another class as the data type, an object of another class is instantiated in a class, any method in a class contains an object with another class as the data type, and any method in a class has another class as the return value type;
[0024] An aggregation module, used for aggregating the class-level multi-layer software network to construct an aggregated class-level software network;
[0025] A measurement class importance indicator construction module, used to construct a measurement class importance indicator based on the aggregated class-level software network;
[0026] A class node importance calculation module, used to calculate the importance of all class nodes in the aggregated class-level software network according to the measurement class importance index;
[0027] A feature dependency network construction module is used to extract the methods, attributes, and interactions between methods and methods, as well as between methods and attributes within each class through static analysis of the software source code, and to construct a feature dependency network within each class;
[0028] A defect tendency determination module for each class, used to determine the defect tendency of each class according to the feature dependency network within each class; the defect tendency is the probability of introducing defects into each class;
[0029] An evaluation module, for evaluating the test importance of a class according to the importance of all class nodes and the probability of all classes introducing defects;
[0030] A test case sequence generation module is used to evaluate the priority of the test case according to the test importance of the class and the coverage information of each test case on the class, arrange the test cases according to the priority, and generate a test case sequence; the coverage information on the class is the set of classes covered by the test case; the priority of the test case is the sum of the test importance of all classes covered by the test case.
[0031] In a third aspect, the present application provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the test case sorting methods described above.
[0032] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the test case sorting methods described above.
[0033] According to the specific embodiments provided in this application, this application discloses the following technical effects:
[0034] This application is based on a class-level multi-layer software network constructed according to the interaction relationship between classes and an aggregated class-level software network, determines the importance of all class nodes, and determines the defect tendency of each class according to the feature dependency network. The test cases are sorted by introducing the importance of class nodes and the defect tendency of classes, taking into account the different importance of classes in the software and the different probabilities of introducing defects for classes of different complexity, thereby improving the accuracy of the test case sorting results, thereby reducing the efficiency of test case error detection and improving the work efficiency of the development team. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. 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 paying creative work.
[0036] Figure 1 A flow chart of a test case sorting method provided in one embodiment of the present application;
[0037] Figure 2 A schematic diagram of a CMN constructed for an embodiment of the present application;
[0038] Figure 3It is a schematic diagram of the class-level software network ACSN;
[0039] Figure 4 A schematic diagram of a FDN constructed for an embodiment of the present application;
[0040] Figure 5 A schematic diagram of another FDN (ActionBar) constructed for an embodiment of the present application;
[0041] Figure 6 Schematic diagram of bs(i,k) calculated for an embodiment of the present application;
[0042] Figure 7 A schematic diagram of avgbs(k) calculated for an embodiment of the present application;
[0043] Figure 8 A log-log plot constructed for an example of the present application. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0045] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0046] The internal structure of software has a significant impact and far-reaching significance on the ordering of test cases. The structure of the software determines the dependencies and interactions between its modules, which directly affect the importance of classes, the probability of class defects, and the propagation and detection of defects. Complex network theory provides a global and holistic perspective to help understand the structure and behavior of software. By drawing on complex network theory, key modules and high-risk areas in the software can be better identified and analyzed, thereby optimizing the priority ordering of test cases. This not only improves the efficiency and coverage of testing, but also detects and fixes key defects as early as possible, thereby significantly improving the overall quality and stability of the software.
[0047] The present application embodiment provides a test case sorting method, which is executed by a computer device, and can be specifically executed by a computer device such as a terminal or a server alone, or can be executed by a terminal and a server together. In the present application embodiment, Figure 1 As shown, the method includes the following steps.
[0048] S1: Extract classes and the interaction relationships between classes in the software source code, and abstract the interaction relationships into a class-level multi-layer software network; the interaction relationships include inheritance relationships between classes, any method in a class throws an exception of another class type, an implementation relationship between a class and an abstract class, any method in a class uses an object of another class as a parameter, a class contains an attribute, and the attribute has another class as the data type, there is a calling relationship between methods of two classes, a method in a class accesses an attribute of another class as the data type, an object of another class is instantiated in a class, any method in a class contains an object of another class as the data type, and any method in a class has another class as the return value type.
[0049] S2: Aggregate the class-level multi-layer software network to build an aggregated class-level software network.
[0050] S3: Based on the aggregated class-level software network, construct a metric to measure class importance.
[0051] S4: Calculate the importance of all class nodes in the aggregated class-level software network according to the metric class importance index.
[0052] S5: Through static analysis of the software source code, the methods, attributes, interactions between methods, and between methods and attributes within each class are extracted to construct a feature dependency network within each class.
[0053] S6: Determine the defect tendency of each class according to the feature dependency network within each class; the defect tendency is the probability of introducing defects into each class.
[0054] S7: Evaluate the test importance of a class according to the importance of all class nodes and the probability of all classes introducing defects.
[0055] S8: According to the test importance of the class and the coverage information of each test case on the class, evaluate the priority of the test case, arrange the test cases according to the priority, and generate a test case sequence; the coverage information on the class is the set of classes covered by the test case; the priority of the test case is the sum of the test importance of all classes covered by the test case.
[0056] In an exemplary embodiment, CMN={NET IN , NET TH , NET IM , NET PA , NET GL , NET ME , NET AC , NET IS , NETLO , NET RE}
[0057] Among them, NET i =(N, L i , W i ) is a specific layer network in the class-level multi-layer software network (the i-th layer single-layer network, the subscript i represents a specific interaction relationship between classes), which is used to abstract classes and a specific interaction relationship between classes i∈{IN, TH, IM, PA, GL, ME, AC, IS, LO, RE}; N is NET i A node set representing all classes in the source code; i NET i The directed edge set of W represents a certain interaction relationship between classes; i is a |N|×|N| matrix (|N| represents the number of class nodes in the node set N), storing the NET i The edge weights of each directed edge in i (k, l) indicates a directed edge<k,l> The edge weight on it is from class node k to class node l); IN indicates the inheritance relationship between classes; TH indicates that a method in a class throws an exception of another class type; IM indicates the implementation relationship between a class and an abstract class; PA indicates that a method in a class uses an object of another class as a parameter; GL indicates that a class contains an attribute, which is of another class data type; ME indicates that there is a calling relationship between methods of two classes; AC indicates that a method in a class accesses an attribute of another class data type; IS indicates that an object of another class is instantiated in a class; LO indicates that a method in a class contains an object of another class data type; RE indicates that a method in a class returns a value of another class.
[0058] Furthermore, there are directed edges in S1 above<k,l> The edge weight W on the node (direction from class node k to class node l) i The calculation of (k, l) specifically includes the following sub-steps:
[0059] (1.1) If i = IN (IN indicates the inheritance relationship between classes): In NET IN For any pair k and l, if there is a directed edge<k,l> , then W IN (k, l) is numerically equal to the number of times class k inherits class l in the entire Java software.
[0060] (1.2) If i = TH (TH means that a method in a class throws an exception of another class type): In NET TH For any pair k and l, if there is a directed edge<k,I> , then WTH (k, l) is numerically equal to the total number of exceptions with data type l thrown from all methods of class k in the entire Java software.
[0061] (1.3) If i = IM (IM represents the implementation relationship between a class and an abstract class): In NET IM For any pair k and l, if there is a directed edge<k,l> , then W IM (k, l) is numerically equal to the number of times class k implements class l in the entire Java software.
[0062] (1.4) If i = PA (PA means that a method in a class uses an object of another class as a parameter): PA For any pair k and l, if there is a directed edge<k,l> , then W PA (k, l) is numerically equal to the number of methods in class k that take objects of class l as parameters in the entire Java software.
[0063] (1.5) If i = GL (GL means a class contains an attribute whose data type is another class): GL For any pair k and l, if there is a directed edge<k,l> , then W GL (k, l) is numerically equal to the number of attributes in class k with data type l in the entire Java software.
[0064] (1.6) If i = ME (ME indicates that there is a calling relationship between the methods of two classes): In NET ME For any pair k and l, if there is a directed edge<k,l> , then W ME (k, l) is numerically equal to the total number of times that methods of class k call methods of class l in the entire Java software.
[0065] (1.7) If i = AC (AC means that a method in a class accesses an attribute whose data type is another class): In NET AC For any pair k and l, if there is a directed edge<k,l> , then W AC (k, l) is numerically equal to the total number of times that methods of class k access attributes of class l in the entire Java software.
[0066] (1.8) If i = IS (IS means that an object of another class is instantiated in one class): In NET IS For any pair k and l, if there is a directed edge<k,l> , then W IS (k, l) is numerically equal to the number of class l objects instantiated by class k in the entire Java software.
[0067] (1.9) If i = LO (LO means that a method of a class contains an object of another class as the data type): In NET LO For any pair k and l, if there is a directed edge<k,l> , then W LO (k, l) is numerically equal to the total number of objects with data type class l defined in methods of class k in the entire Java software.
[0068] (1.10) If i = RE (RE means a method in a class returns another class): RE For any pair k and l, if there is a directed edge<k,l> , then W RE (k, l) is numerically equal to the total number of methods of class k in the entire Java software that have a return value type of class l.
[0069] In an exemplary embodiment, S2 may be replaced by the following steps:
[0070] The node set of the class-level multi-layer software network is used as the node set of the aggregate class-level software network; if the class node pair<k,j> In the class-level multi-layer software network, there is a directed edge from class node k to class node j, and it is determined that the aggregated class-level software network has a directed edge from class node k to class node j; the edge weight of the directed edge is determined according to the strength value and the number of occurrences of the interaction relationship; and an aggregated class-level software network is constructed according to the node set of the aggregated class-level software network, the directed edge and the edge weight.
[0071] Furthermore, the construction of the aggregated class-level software network specifically includes the following sub-steps:
[0072] (2.1) Node construction: The node set of the aggregated class-level software network (ACSN) is the same as the node set of the class-level multilayer software network (CMN).
[0073] (2.2) Directed edge construction: If the class node pair k and l are in at least one NET of the CMN i =(N, L i , W i ) has a directed edge from node k to node l, then there is a directed edge from class node k to class node l in ACSN<k,l> . i∈{lN, TH, IM, PA, GL, ME, AC, IS, LO, RE}.
[0074] (2.3) Edge Weight Calculation: Directed Edges in ACSN<k,l> The edge weight w(k, l) = S IN *W IN (k, l)+S TH *W TH (k, l)+S IM *W IM (k, l)+S PA *W PA (k, l)+S GL *W GL (k, l)+S ME *W ME (k, l)+S AC *W AC (k, l)+S IS *W IS (k, l)+S LO *W LO (k, l)+S RE *W RE (k, l). Where S i , W i (k, l)(i∈{IN, TH, IM, PA, GL, ME, AC, IS, LO, RE}) represents the strength value and number of occurrences of interaction type i. Therefore, w(k, l) is numerically equal to the sum of the number of occurrences of node k and node l in different layers of the CMN network multiplied by the strength of the interaction type at that layer. In this application, S IN =3, S TH =2, S IM =4, S PA =3, S GL =3, S ME =2, S AC =2, S IS =2, S LO =1, S RE = 3. These values are widely recognized in the field.
[0075] In an exemplary embodiment, S4 may be replaced by the following steps:
[0076] Calculate the set of class nodes directly connected to class node i in the aggregated class-level software network; calculate the weighted degrees of all class nodes in the class node set, and arrange all class nodes in the class node set according to the weighted degrees to generate a sorted class node list; the weighted degree is the sum of the edge weights of all edges connected to the class node; determine the weighted h-index of each class node according to the class node list; traverse each class node in the aggregated class-level software network to determine the set of nodes whose shortest path length with class node i does not exceed 3; traverse each class node in the node set to determine class node parameters; the class node parameters include the shortest path length between class node i and class node j, the number of paths with a length of len between class node i and class node j, and the number of all paths with a length of len with class node j; construct the importance of the class node according to the weighted h-index and the class node parameters.
[0077] Furthermore, the calculation of the weighted h-index wh(i) of class node i includes the following steps:
[0078] (3.1) Find the weighted degree wd(i) of class node i in ACSN, that is, the sum of the edge weights of all edges connected to class node j in ACSN.
[0079] (3.2) Find the set nb of class nodes in ACSN that are directly connected to class node i by edges i .
[0080] (3.3) Calculate nb according to step (3.1) i The weighted degrees of all class nodes in nb, and sort them in descending order according to the weighted degrees i All class nodes in (if the weights of two classes of nodes are equal, the two classes of nodes are randomly arranged). If the sorted class node list is LI (LI (1) is the first element of the list, which stores the class node with the largest weight).
[0081] (3.4) Starting from LI[1], check the weighted degree of each class node in LI in turn, and find the first class node LI(n+1) whose weighted degree is less than (n+1). Then the weighted h-index wh(i) of class node i is n.
[0082] Furthermore, the calculation of the importance of all class nodes in ACSN in S4 specifically includes the following steps:
[0083] (4.1) Traverse each node in ACSN and calculate the weighted h-index of each node according to steps (3.1) to (3.4).
[0084] (4.2) Traverse each node in ACSN, if the current node is i
[0085] (4.2.1) Find φ 3(i), that is, the set of nodes in ACSN whose shortest path length to class node i does not exceed 3.
[0086] (4.2.2) Traverse φ in sequence 3 Each node in (i).
[0087] (4.2.2.1) If you are currently traversing φ 3 (i) Find the length s of the shortest path between class nodes i and class nodes j. i,j .
[0088] (4.2.2.2) Let len be from s i,j Increase in steps of 1 to 3, for each len value
[0089] (4.2.2.2.1) Find the number of paths of length len between node i and class node j
[0090] (4.2.2.2.2) Find the number of all paths with length len to class node j in ACSN
[0091] (4.2.3) Based on the result of step (4.2.2), calculate
[0092] (4.2.4) Calculate CR(i) based on the result obtained in step (4.2)
[0093]
[0094] Among them, CR(i) is the importance of class node i; φ 3 (i) is the set of nodes whose shortest path length to class node i does not exceed 3; s i,j is the shortest path length between class node i and class node j; is the number of paths of length len between class node i and class node j in the aggregated class-level software network; h is any node in the node set N of the aggregated class-level software network; is the number of all paths with a length of len with class node j in the aggregated class-level software network; wh(i) and wh(j) are the weighted h-indexes of class nodes i and j in the aggregated class-level software network.
[0095] In an exemplary embodiment, S6 may be replaced by the following steps:
[0096] Calculate the shortest path length between all feature nodes in the feature dependency network corresponding to class node i to generate a shortest path length set; sort the shortest paths in the shortest path length set to generate an ordered sequence; based on the ordered sequence, calculate the longest path length between all feature nodes in the feature dependency network, the weighted degree of the feature node and the weight in the ordered sequence domain; display the weight in the ordered sequence domain and the mean of the weight in the ordered sequence domain on a log-log coordinate system, and perform linear regression fitting to generate a fitting curve; use the absolute value of the slope of the fitting curve as the geometric dimension of the class node i; determine the defect tendency of class node i based on the maximum value of the geometric dimension of the class node i and the geometric dimensions of all classes.
[0097] Furthermore, the calculation of the probability of a class introducing a defect in the above step (6) specifically includes the following sub-steps:
[0098] (6.1) Calculate the shortest path length (the minimum value of the sum of the inverse of the edge weights on the path) between all feature nodes in the feature dependency network (FDN) corresponding to class i, and form a set disSet with these shortest path lengths. Where FDN = (N f , L f , W f );N f is a set of nodes of FDN, representing the features (i.e., methods and attributes) in a particular class; L f is the directed edge set of FDN, representing the interaction relationship between features in the class (i.e., method call, method usage attribute); W f Is a |N f |×|N f The matrix (|N f | indicates N f The number of nodes in FDN stores the edge weights of all directed edges in FDN; W f (k, l) indicates a directed edge<k,l> The edge weight on the feature node is from feature node k to feature node l, indicating that feature k accesses (calls) feature l. f (k, l) times.
[0099] (6.2) Arrange the shortest paths in disSet in ascending order, i.e., disSet = {d 1 , d 2 , d 3 , ..., d n}(n represents the number of node pairs), d 1 Minimum, d n maximum.
[0100] (6.3) Based on the ordered sequence obtained in step (6.2), calculate bs 1 =d 1 , bs 2 =d 1 +d 2 , ..., bs n =d 1 +d 2 +...+d n .
[0101] (6.4) Calculate the longest path length between all feature nodes in FDN (the maximum value of the sum of the inverses of the edge weights on the path) and let its value be D.
[0102] (6.5) Calculate the weighted degree of the characteristic node in FDN. The weighted degree of a characteristic node is defined as the sum of the edge weights of the edges connected to the node.
[0103] (6.6) Calculate the bs of any feature node i in FDN k (k=1,2,...,n) domain weight bs(i,k). bsk(i,k) is equal to the shortest path of all feature nodes i in bs k The sum of the weighted degrees of the feature nodes within.
[0104] (6.7) Calculate bs k The average weight in the field is avgbs(k), that is,
[0105] avgbs(k)=∑ i bs(i, k) / N
[0106] Wherein, N is the number of characteristic nodes in the FDN, and i is any characteristic node in the FDN.
[0107] (6.8) bs k and avgbs(k) are displayed on a log-loglog-log coordinate system, and linear regression is used to fit these points. The absolute value of the slope is the geometric dimension GD(i) of class i.
[0108] (6.9) The probability of class i introducing a defect is bip(i) = GD(i) / MAXGD, where MAXGD is the maximum geometric dimension of all classes in the system.
[0109] In an exemplary embodiment, the test importance of the class is:
[0110] CTI(i)=CR(i)×bip(i) / MAXCR
[0111] Among them, CTI(i) is the test importance of class node i; CR(i) is the importance of class node i; bip(i) is the defect tendency of class node i; MAXCR is the maximum value of the importance of all class nodes.
[0112] In an exemplary embodiment, S8 may be replaced by the following steps:
[0113] Count the class set covered by the current test case; based on the class set, calculate the importance of the current test case according to the test importance of all covered classes; determine the priority of the test case according to the importance of the current test case; arrange all test cases in descending order according to the priority and generate a test case sequence.
[0114] Further, all test cases are traversed in sequence.
[0115] (8.1.1) If the current test case is i, count the set of classes covered by the test case covc(i)
[0116] (8.1.2) The test importance of test case i is the sum of the test importance of the classes it covers, that is,
[0117]
[0118] Where j is any class covered by test case i.
[0119] According to step (8.1), the test priorities of all test cases are obtained, and then the test cases are arranged in descending order of priority. The test cases are executed in the sorted order.
[0120] The following code is used as an example to illustrate the technical solution of this application.
[0121] The Java source code snippet is as follows:
[0122]
[0123]
[0124] The embodiment shown in the Java source code snippet includes 5 classes (P1.M, P1.A, P1.D, P2.O, P3.Z) and 10 interactions between these 5 classes (IN, TH, IM, PA, GL, ME, AC, IS, LO, RE). The application uses the comment / ** / to mark the location where each interaction occurs. According to the definition of CMN, the application will build 10 single-layer networks (such as Figure 2 Shown): NET IN , NET TH , NET IM , NETPA , NET GL , NET ME , NET AC , NET IS , NET LO , NET RE Each network represents a specific interaction relationship. IM As an example, due to the construction of Figure 2 As shown) contains 5 classes, so in the corresponding NET IM There are 5 class nodes in it. At the same time, because P1.M implements P1.A (see the code class M extends Throwableimplements A), there is a directed edge between nodes P1.M and P1.A (from P1.M to P1.A). Since P1.M only implements P1.A once in the entire code snippet, the edge weight of edge P1.M->P1.A is 1.
[0125] This application provides a test case sorting method, the steps are as follows:
[0126] (1) Parse Java software source code, extract classes and various relationships between classes, and abstract the relationships between classes into a class-level multi-layer software network
[0127] CMN = {NET IN , NET TH , NET IM , NET PA , NET GL , NET ME , NET AC , NET IS , NET LO , NET RE}
[0128] Among them, NET i =(N, L i , W i ) is a specific layer network in the class-level multi-layer software network (the i-th layer single-layer network, the subscript i represents a specific interaction relationship between classes), which is used to abstract classes and a specific interaction relationship between classes i∈{IN, TH, IM, PA, GL, ME, AC, IS, LO, RE}; N is NET i A node set representing all classes in the source code; i NET i The directed edge set of W represents a certain interaction relationship between classes; i is a |N|×|N| matrix (|N| represents the number of class nodes in the node set N), storing the NETi The edge weights of each directed edge in i (k, l) indicates a directed edge<k,l> The edge weight on it is from class node k to class node l); IN indicates the inheritance relationship between classes; TH indicates that a method in a class throws an exception of another class type; IM indicates the implementation relationship between a class and an abstract class; PA indicates that a method in a class uses an object of another class as a parameter; GL indicates that a class contains an attribute, which is of another class data type; ME indicates that there is a calling relationship between methods of two classes; AC indicates that a method in a class accesses an attribute of another class data type; IS indicates that an object of another class is instantiated in a class; LO indicates that a method in a class contains an object of another class data type; RE indicates that a method in a class returns a value of another class.
[0129] (2) The class-level multi-layer software network is aggregated to construct an aggregated class-level software network, which specifically includes:
[0130] (2.1) Node construction: The node set of the aggregated class-level software network ACSN is the same as the node set of the class-level multi-layer software network CMN. For example, in an embodiment, Figure 3 The node set of ACSN shown is Figure 2 The node sets of the CMNs shown are identical.
[0131] (2.2) Directed edge construction: If the class node pair k and l are in at least one NET of the CMN i =(N, L i , W i ) has a directed edge from node k to node l, then there is a directed edge from class node k to class node l in ACSN<k,l> i∈{IN, TH, IM, PA, GL, ME, AC, IS, LO, RE}. For example, in the embodiment, there is a directed edge between nodes P1.M and P1.A in NETIM.<P1.M,P1.A> (like Figure 2 As shown in , there is no edge between these two nodes in other single-layer networks), so in the corresponding ACSN (such as Figure 3 There is also a directed edge between these two nodes.<P1.M,P1.A> .
[0132] (2.3) Edge Weight Calculation: Directed Edges in ACSN<k,l> The edge weight w(k, l) = S IN *W IN (k, l)+S TH *W TH (k, l)+S IM *W IM (k, l)+S PA*W PA (k, l)+S GL *W GL (k, l)+S ME *W ME (k, l)+S AC *W AC (k, l)+S IS *W IS (k, l)+S LO *W LO (k, l)+S RE *W RE (k, l). Where S i , W i (k, l)(i∈{IN, TH, IM, PA, GL, ME, AC, IS, LO, RE}) represents the strength value and number of occurrences of interaction type i. Therefore, w(k, l) is numerically equal to the sum of the number of occurrences of node k and node i in different layers of the CMN network multiplied by the strength of the interaction type at that layer. In this application, S IN =3, S TH =2, S IM =4, S PA =3, S GL =3, S ME =2, S AC =2, S IS =2, S LO =1, S RE =3. These values are widely recognized in the field. For example, in the embodiment (such as Figure 2 As shown in Figure 2, there is a TH relationship, an IS relationship, a LO relationship, and a RE relationship between P2.O and P1.D. Therefore, in ACSN, the edge<P2.O,P1.D> The edge weight = 2*1+2*1+1*1+3*1=8.
[0133] (3) Based on the aggregated class-level software network, we construct the index CR to measure the importance of the class. CR is defined as follows:
[0134]
[0135] Among them, CR(i) represents the importance of class node i in ACSN; represents the number of paths of length len between class node i and class node j in ACSN; N represents the node set of ACSN; h is any node in N; represents the number of all paths with length len in ACSN and class node j; s i,j is the length of the shortest path between class node i and class node j in ACSN; φ 3(i) represents the set of nodes in ACSN whose shortest path length with class node i does not exceed 3; wh(i) and wh(j) represent the weighted h-index of class nodes i and j in ACSN.
[0136] The calculation of the weighted h-index wh(i) of class node i includes the following steps (with Figure 3 Take the middle class P2.O as an example):
[0137] (3.1) Find the weighted degree wd(i) of class node i in ACSN, that is, the sum of the edge weights of all edges connected to class node i in ACSN. Therefore, wd(P2.O)=8+12=20.
[0138] (3.2) Find the set nb of class nodes in ACSN that are directly connected to class node i by edges i Therefore, nb P2.O ={P1.D,P3.Z}.
[0139] (3.3) Calculate nb according to step (3.1) i The weighted degrees of all class nodes in nb, and sort them in descending order according to the weighted degrees i All class nodes in (if the weights of two classes of nodes are equal, the two classes of nodes are randomly arranged). If the sorted class node list is LI (LI (1) is the first element of the list, which stores the class node with the largest weight). Therefore, wd (P1.D) = 3 + 8 + 2 = 13, wd (P3.Z) = 2 + 12 = 14. After sorting, P3.Z>P1.D.
[0140] (3.4) Starting from LI[1], check the weighted degree of each class node in LI in turn, find the first class node LI(n+1), whose weighted degree is less than (n+1), then the weighted h index wh(i) of class node i is n. In the embodiment, because LI(1)=wd(P3.Z)=14>(1+1), LI(2)=wd(P1.D)=13>(2+1). P2.O has no other neighbor nodes, so wh(P2.O)=2.
[0141] Similarly, we can obtain wh(P1.A)=1, wh(P1.M)=2, wh(P1.D)=2, and wh(P3.Z)=2.
[0142] (4) Using CR to calculate the importance of all class nodes in the aggregated class-level software network, specifically including the following steps:
[0143] (4.1) Traverse each node in the ACSN and calculate the weighted h-index of each node according to steps (3.1) to (3.4). Figure 3shown), wh(P1.A)=1, wh(P1.M)=2, wh(P1.D)=2, wh(P2.O)=2, wh(P3.Z)=2.
[0144] (4.2) Traverse each node in ACSN. If the current node is i, perform the following steps.
[0145] (4.2.1) Find φ 3 (i), that is, the set of nodes in the ACSN whose shortest path length to class node i does not exceed 3. In the embodiment, if the current node i = P1.A, then φ 3 (P1.A)={P1.M,P1.D,P2.O,P3.Z}.
[0146] (4.2.2) Traverse φ in sequence 3 Each node in (i).
[0147] (4.2.2.1) If you are currently traversing φ 3 (i) Find the length s of the shortest path between class nodes i and class nodes j. i,j In the embodiment, assuming that the current node j=P1.M, the shortest path length from i to j is 1 (the edge weight and the direction of the edge are not considered when calculating the shortest path).
[0148] (4.2.2.2) Let len be from s i,j Increase in steps of 1 to 3, for each len value
[0149] (4.2.2.2.1) Find the number of paths of length len between node i and class node j
[0150] In the embodiment, assuming that the current node i=P1.A, j=P1.M, len=1, then
[0151] (4.2.2.2.2) Find the number of all paths with length len to class node j in ACSN In the embodiment, assuming that the current node i = P1.A, j = P1.M, len = 1, then all path numbers (i.e. P1.D to P1.M, P1.A to P1.M).
[0152] (4.2.3) Based on the result of step (4.2.2), calculate In the embodiment, assuming that the current node i = P1.A, j = P1.M, len = 1, it can be obtained Assume that the current node i=P1.A、j=P1.M,len=2,there is no shortest path with len=2, Assume that the current node i=P1.A、j=P1.M,len=3, and there is no shortest path with len=3.
[0153] (4.2.4) Calculate CR(i) based on the result obtained in step (4.2)
[0154]
[0155] In the embodiment, assuming that the current node i = P1.A, j = P1.M, we can get Similarly, assuming that the current node i = P1.A, j = P1.D, we can get Assuming that the current node i=P1.A, j=P1.O, we can get Assuming that the current node i=P1.A, j=P1.Z, we can get therefore,
[0156] (5) Through static analysis of the source code, the methods, attributes and the interaction between methods and attributes in each class are extracted, and then the feature dependency network FDN = (N f , L f , W f ).
[0157] Among them, N f is a set of nodes of FDN, representing the features (i.e., methods and attributes) in a particular class; L f is the directed edge set of FDN, representing the interaction relationship between features in the class (i.e., method call, method usage attribute); W f Is a |N f |×|N f The matrix (|N f | indicates N f The number of nodes in FDN stores the edge weights of all directed edges in FDN; W f (k, l) indicates a directed edge<k,l> The edge weight on the feature node is from feature node k to feature node l, indicating that feature k accesses (calls) feature l. f (k, l) times. Figure 4 ) shows a code snippet and its corresponding FDN. Specifically, because class p1.classX contains 4 features (i.e., 1 attribute and 3 methods), the corresponding FDN contains 4 nodes; at the same time, a() accesses v, b() calls a(), and c() accesses v, so there is a directed edge between the corresponding features in the FDN (the edge weight is 1).
[0158] (6) Based on the feature dependency network of each class constructed in step (5), the probability of the class introducing defects is calculated, and then the probability of all classes in the system entering defects is calculated. Figure 4 The embodiment is too simple. In order to more comprehensively demonstrate the calculation process, this application introduces Figure 5 Embodiment of the invention. Figure 5 The displayed FDN is constructed from the ActionBar class of the real software jedit-4.2. The calculation of the probability that the ActionBar class introduces a defect includes:
[0159] (6.1) Calculate the shortest path lengths between all feature nodes in the FDN corresponding to class i (the minimum value of the sum of the inverses of the edge weights on the path), and form a set disSet with these shortest path lengths (duplicate elements are allowed in the set in this application). Figure 5 In the embodiment, the shortest paths between nodes are shown in Table 1. Therefore, disSet = {0.25, 0.17, 0.67, 1.00, 100, 0.17, 0.20, 0.33, 1.00, 0.50, 1.00, 0.33, 1.00, 0.50, 1.00, 1.00}.
[0160] Table 1 The shortest path table between nodes
[0161]
[0162]
[0163] (6.2) Arrange the shortest paths in disSet in ascending order, i.e., disSet = {d 1 ,d 2 ,d 3 ,…,d n}(n represents the number of node pairs),d 1 Minimum, d n Maximum, that is: 0.17(d 1 )≤0.17(d 2 )<0.20(d 3 )<0.25(d 4 )<0.33(d 5 )≤0.33(d 6 )<0.50(d 7 )≤0.50(d 8 )<0.67(d 9 )<1.00(d 10 )≤(d 11 )≤1.00(d 12 )≤1.00(d 13 )≤1.00(d14 )≤1.00(d 15 )≤1.0(d 16 ).
[0164] (6.3) Based on the ordered sequence obtained in step (6.2), calculate bs 1 =d 1 ,bs 2 =d 1 +d 2 ,…,bs n =d 1 +d 2 +…+d n , that is: bs 1 =0.17,bs 2 =0.34,bs 3 =0.54,bs 4 =0.79,bs 5 =1.12,bs 6 =1.45,bs 7 =1.95,bs 8 =2.45,bs 9 =3.12,bs 10 =4.12,bs 11 =5.12,bs 12 =6.12,bs 13 =7.12,bs 14 =8.12,bs 15 =9.12, and bs 16 =10.12
[0165] (6.4) Calculate the longest path length between all feature nodes in FDN (the maximum value of the sum of the inverses of the edge weights on the path), and let its value be D. In the above example, the distance between repeatCount and temp is the largest, which is 3, that is, D=3.
[0166] (6.5) Calculate the weighted degree of the characteristic node in FDN. The weighted degree of a characteristic node is defined as the sum of the edge weights of the edges connected to the node. The results are shown in Table 2 (the first column in Table 2 lists the node numbers).
[0167] Table 2 Node weight table.
[0168]
[0169]
[0170] (6.6) Calculate the bs of any feature node i in FDN k(k=1,2,...,n) domain weight bs(i,k). bsK(i,k) is equal to the shortest path of all feature nodes i in bs k The sum of the weighted degrees of the feature nodes within. Figure 5 The sum of the weights of the midpoints is Figure 6 shown.
[0171] (6.7) Calculate bs k The average weight in the field is avgbs(k), that is,
[0172] avgbs(k)=∑ i bs(i, k) / N
[0173] Wherein, N is the number of characteristic nodes in the FDN, and i is any characteristic node in the FDN. Figure 5 Different bs obtained in k The average weight avgbs(k) in the field is as follows Figure 7 shown.
[0174] (6.8) bs k and avgbs(k) are displayed on a log-log coordinate system, and linear regression is used to fit these points. The absolute value of the slope is the geometric dimension GD(i) of class i. For the ActionBar class, its log-log graph is as follows Figure 8 shown. Figure 8 The slope of the straight line is 0.82212, that is, GD(ActionBar)=0.82212.
[0175] (6.9) The probability of class i introducing a defect is bip(i) = GD(i) / MAXGD. MAXGD is the maximum value of the geometric dimensions of all classes in the system. In the embodiment, assuming that MAXGD = 0.95231 in the entire system, then bip(ActionBar) = 0.82212 / 0.95231 = 0.86329.
[0176] (7) Based on the importance of the class obtained in step (3) and the probability of the class introducing defects (the defect tendency of the class) obtained in step (6), the test importance of the class is evaluated. The test importance of the class is calculated according to the following formula:
[0177] CTI(i)=CR(i)×bip(i) / MAXCR
[0178] Among them, CTI(i) represents the test importance of class i; CR(i) represents the importance of class i obtained in step (3); bip(i) represents the probability of class i introducing defects obtained in step (6); MAXCR represents the maximum value of CR values of all classes.
[0179] In an embodiment, Assume that bip(P1.A)=0.86329, but
[0180] (8) Based on the test importance of the class obtained in step (7) and the coverage information of each test case on the class, the priority of the test case is evaluated, and then the test cases are arranged in descending order of priority. The test cases are executed in the sorted order.
[0181] The calculation of test case priority specifically includes the following sub-steps:
[0182] (8.1) Traverse all test cases one by one
[0183] (8.1.1) If the current test case is i, count the set of classes covered by the test case covc(i)
[0184] (8.1.2) The test importance of test case i is the sum of the test importance of the classes it covers, that is,
[0185]
[0186] Where j is any class covered by test case i.
[0187] In this embodiment, assume that there are five test cases: tc1, tc2, tc3, tc4, tc5. Figure 3 The coverage of classes in ACSN is as follows: covc(tc1): P1.A, P1.M, P3.Z; covc(tc2): P1.D, P2.O, P3.Z; covc(tc3): P1.A, P1.M, P2.D; covc(tc4): P1.A, P1.M, P2.O; covc(tc5): P1.A, P1.D, P3.Z.
[0188] Assume that CTI(P1.A)=0.44, CTI(P1.M)=0.44, CTI(P1.D)=0.81, CTI(P2.O)=0.24, CTI(P3.Z)=0.92.
[0189] Therefore, the test importance of each test case is: TCI(tc1)=0.44+0.44+0.92=1.8, TCI(tc2)=0.81+0.24+0.92=1.997, TCI(tc3)=0.44+0.4+0.81=1.69, TCI(tc4)=0.44+0.44+0.24=1.12, TCI(tc5)=0.44+0.81+0.92=2.17.
[0190] Arrange the test cases in descending order of priority, i.e., TCI(tc5)>TCI(tc2)>TCI(tc1)>TCI(tc3)>TCI(tc4). Therefore, the test cases are executed in the order of tc5, tc2, tc1, tc3, tc4.
[0191] (1) The test case sorting method proposed in this application comprehensively considers the different importance and defect tendencies of the classes covered by the test cases, which can improve the efficiency and coverage of the test, help to discover and repair key defects as early as possible, and thus significantly improve the overall quality and stability of the software.
[0192] (2) This application proposes the CR index and the BIP index to evaluate the importance of a class in software and the probability of a class introducing defects. CR considers the weighted h-index of the class node and the impact of the software's (direct and indirect) topological structure on the importance of the class. Compared with existing class importance indicators, the CR index can better reflect the importance of the class. The BIP index considers the weighted degree of the node and the path length and number of paths between nodes, which can more comprehensively reflect the complexity of the class and is therefore more suitable for evaluating the defect tendency of the class.
[0193] Based on the same inventive concept, the embodiment of the present application also provides a test case sorting device for implementing the test case sorting method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more test case sorting device embodiments provided below can refer to the limitations of the test case sorting method above, and will not be repeated here.
[0194] In an exemplary embodiment, a test case sorting device is provided, comprising:
[0195] The class-level multi-layer software network construction module is used to extract classes and the interaction relationships between classes in the software source code, and abstract the interaction relationships into a class-level multi-layer software network; the interaction relationships include inheritance relationships between classes, any method in a class throws an exception with another class as the type, the implementation relationship between a class and an abstract class, any method in a class uses an object of another class as a parameter, a class contains an attribute, and the attribute has another class as the data type, there is a calling relationship between methods of two classes, a method in a class accesses an attribute with another class as the data type, an object of another class is instantiated in a class, any method in a class contains an object with another class as the data type, and any method in a class uses another class as the return value type.
[0196] The aggregation module is used to aggregate the class-level multi-layer software network to construct an aggregated class-level software network.
[0197] The module for constructing a measurement class importance index is used to construct a measurement class importance index based on the aggregated class-level software network.
[0198] The class node importance calculation module is used to calculate the importance of all class nodes in the aggregated class-level software network according to the measurement class importance index.
[0199] The feature dependency network construction module is used to extract the methods, attributes, methods and methods, and the interaction between methods and attributes within each class through static analysis of the software source code, and to construct a feature dependency network within each class.
[0200] The defect tendency determination module of each class is used to determine the defect tendency of each class according to the feature dependency network inside each class; the defect tendency is the probability of introducing defects into each class.
[0201] The evaluation module is used to evaluate the test importance of a class according to the importance of all class nodes and the probability of all classes introducing defects.
[0202] A test case sequence generation module is used to evaluate the priority of the test case according to the test importance of the class and the coverage information of each test case on the class, arrange the test cases according to the priority, and generate a test case sequence; the coverage information on the class is the set of classes covered by the test case; the priority of the test case is the sum of the test importance of all classes covered by the test case.
[0203] In the application, the priority of the test cases takes into account multiple characteristics of the classes covered by the test cases, including the importance of the classes and the probability of the classes introducing defects, which is quite different from the traditional test case sorting method based only on the number of covered classes. In addition, compared with the existing related technologies, this application considers more types of interactions between classes when constructing an aggregated class-level software network, and proposes new metrics to evaluate the importance of classes and the probability of defects. This application takes into account more factors when sorting test cases, which can make up for the shortcomings of the existing technology and improve the efficiency of test case error detection. It is of great significance to improve the efficiency of software maintenance and the quality of software, and provides technical support for the country to develop high-trust software.
[0204] In an exemplary embodiment, a computer device is provided, which may be a server or a terminal. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store test case sorting data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a test case sorting method is implemented.
[0205] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the above method is implemented when the processor executes the computer program.
[0206] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the above method when executed by a processor.
[0207] In this application, all actions to obtain signals, information or data are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0208] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0209] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A test case sorting method, characterized in that: The test case sorting method comprises: Extract classes and the interaction between classes in the software source code, and abstract the interaction into a class-level multi-layer software network; the interaction includes inheritance between classes, any method in a class throws an exception with another class as the type, the implementation relationship between a class and an abstract class, any method in a class uses an object of another class as a parameter, a class contains an attribute, and the attribute has another class as the data type, there is a calling relationship between methods of two classes, a method in a class accesses an attribute with another class as the data type, an object of another class is instantiated in a class, any method in a class contains an object with another class as the data type, and any method in a class uses another class as the return value type; Aggregating the class-level multi-layer software network to construct an aggregated class-level software network; Based on the aggregated class-level software network, constructing a metric to measure class importance; Calculating the importance of all class nodes in the aggregated class-level software network according to the metric class importance index; Through static analysis of the software source code, the methods, attributes, and interactions between methods and methods, as well as between methods and attributes within each class are extracted, and a feature dependency network within each class is constructed; Determine the defect tendency of each class according to the feature dependency network within each class; the defect tendency is the probability of introducing defects into each class; Evaluate the test importance of a class based on the importance of all class nodes and the probability of all classes introducing defects; According to the test importance of the class and the coverage information of each test case on the class, the priority of the test case is evaluated, and the test cases are arranged according to the priority to generate a test case sequence; the coverage information on the class is the set of classes covered by the test case; the priority of the test case is the sum of the test importance of all classes covered by the test case.
2. The test case sorting method according to claim 1, characterized in that: Aggregating the class-level multi-layer software network to construct an aggregated class-level software network specifically includes: Using the node set of the class-level multi-layer software network as the node set of the aggregated class-level software network; If the class node pair<k,j> There exists a directed edge from class node k to class node j in the class-level multi-layer software network, and it is determined that there exists a directed edge from class node k to class node j in the aggregated class-level software network; Determine the edge weight of the directed edge according to the strength value and the number of occurrences of the interaction relationship; An aggregated class-level software network is constructed according to the node set of the aggregated class-level software network, the directed edges, and the edge weights.
3. The test case sorting method according to claim 1, characterized in that: Calculating the importance of all class nodes in the aggregated class-level software network according to the metric class importance index specifically includes: Calculate the set of class nodes directly connected to the class node i in the aggregated class-level software network; Calculating the weighted degrees of all class nodes in the class node set, and arranging all class nodes in the class node set according to the weighted degrees to generate a sorted class node list; the weighted degree is the sum of the edge weights of all edges connected to the class node; Determining a weighted h-index for each class node according to the class node list; Traversing each class node in the aggregated class-level software network, and determining a set of nodes whose shortest path length to class node i does not exceed 3; Traversing each class node in the node set to determine class node parameters; the class node parameters include the shortest path length between class node i and class node j, the number of paths with a length of len between class node i and class node j, and the number of all paths with a length of len with class node j; The importance of the class node is constructed according to the weighted h-index and the class node parameters.
4. The test case sorting method according to claim 3, characterized in that: The importance of the class nodes is: Among them, CR(i) is the importance of class node i; φ3(i) is the set of nodes whose shortest path length to class node i does not exceed 3; s i,j is the shortest path length between class node i and class node j; is the number of paths of length len between class node i and class node j in the aggregated class-level software network; h is any node in the node set N of the aggregated class-level software network; is the number of all paths with a length of len with class node j in the aggregated class-level software network; wh(i) and wh(j) are the weighted h-indexes of class nodes i and j in the aggregated class-level software network.
5. The test case sorting method according to claim 1, characterized in that: According to the feature dependency network within each class, the defect tendency of each class is determined, including: Calculate the shortest path length between all feature nodes in the feature dependency network corresponding to class node i and generate a set of shortest path lengths; Sorting the shortest paths in the shortest path length set to generate an ordered sequence; Based on the ordered sequence, the longest path length between all feature nodes in the feature dependency network, the weighted degree of the feature nodes, and the weight within the ordered sequence domain are calculated; The weights in the ordered sequence domain and the mean of the weights in the ordered sequence domain are displayed on a log-log coordinate system, and linear regression fitting is performed to generate a fitting curve; The absolute value of the slope of the fitting curve is used as the geometric dimension of the class node i; The defect tendency of the class node i is determined according to the geometric dimension of the class node i and the maximum value of the geometric dimensions of all classes.
6. The test case sorting method according to claim 1, characterized in that: The test importance of the said classes is: CTI(i)=CR(i)×bip(i) / MAXCR Among them, CTI(i) is the test importance of class node i; CR(i) is the importance of class node i; bip(i) is the defect tendency of class node i; MAXCR is the maximum value of the importance of all class nodes.
7. The test case sorting method according to claim 1, characterized in that: According to the test importance of the class and the coverage information of each test case on the class, the priority of the test case is evaluated, and the test cases are arranged according to the priority to generate a test case sequence, which specifically includes: Count the class set covered by the current test case; Based on the class set, calculating the importance of the current test case according to the test importance of all covered classes; Determine the priority of the test case according to the importance of the current test case; Arrange all test cases in descending order of priority to generate a test case sequence.
8. A test case sorting device, characterized in that: The test case sorting device comprises: A class-level multi-layer software network construction module is used to extract classes and the interaction relationships between classes in the software source code, and abstract the interaction relationships into a class-level multi-layer software network; the interaction relationships include inheritance relationships between classes, any method in a class throws an exception with another class as the type, an implementation relationship between a class and an abstract class, any method in a class uses an object of another class as a parameter, a class contains an attribute, and the attribute has another class as the data type, there is a calling relationship between methods of two classes, a method in a class accesses an attribute with another class as the data type, an object of another class is instantiated in a class, any method in a class contains an object with another class as the data type, and any method in a class has another class as the return value type; An aggregation module, used for aggregating the class-level multi-layer software network to construct an aggregated class-level software network; A measurement class importance indicator construction module, used to construct a measurement class importance indicator based on the aggregated class-level software network; A class node importance calculation module, used to calculate the importance of all class nodes in the aggregated class-level software network according to the measurement class importance index; A feature dependency network construction module is used to extract the methods, attributes, and interactions between methods and methods, as well as between methods and attributes within each class through static analysis of the software source code, and to construct a feature dependency network within each class; A defect tendency determination module for each class, used to determine the defect tendency of each class according to the feature dependency network within each class; the defect tendency is the probability of introducing defects into each class; An evaluation module, for evaluating the test importance of a class according to the importance of all class nodes and the probability of all classes introducing defects; A test case sequence generation module is used to evaluate the priority of the test case according to the test importance of the class and the coverage information of each test case on the class, arrange the test cases according to the priority, and generate a test case sequence; the coverage information on the class is the set of classes covered by the test case; the priority of the test case is the sum of the test importance of all classes covered by the test case.
9. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the test case sorting method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the test case sorting method described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Test case priority ranking method and system based on test heterogeneous graph
CN120872847A