A test sequence generation method based on network node importance
Patent Information
- Application Number
- CN202210719782.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2042-06-23
AI Technical Summary
然而,该类方法存在图论方法存在的普遍问题,即面对复杂软件时的计算复杂度较高,且生成的测试序列几乎是唯一的,难以保证可以获得最优解,尤其是在目标不只一个的情况下,无法提供足够数量的相对最优解以供决策
[0027] The advantages of this invention compared to existing technologies are as follows: Existing software integration test sequence generation methods only employ a few graph theory methods that prioritize testing important software modules. However, these methods suffer from high computational complexity when dealing with complex software, and the generated test sequences are almost unique, making it difficult to guarantee optimal solutions. This invention overcomes the shortcomings of existing technologies by providing a test sequence generation method based on a rebirth multi-objective optimization algorithm. It constructs a test sequence generation method based on network node importance, designs a novel test coverage criterion (fitness function) based on important nodes in the software network and test costs, and applies it to the rebirth multi-objective optimization algorithm for test sequence generation. This ensures that the generated test sequences maximize the coverage of important nodes while minimizing test costs. This invention is applicable to solving the test sequence generation problem in practical software integration testing. It helps software testers design test sequences that meet requirements, reducing testing costs and improving testing efficiency while creating test sequences with higher software defect detection capabilities. It has high practical application value.
Smart Images

Figure CN115221043B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of software trustworthiness and software testing technology, and in particular to a method for generating test sequences based on the importance of network nodes. Background Technology
[0002] Integration testing is a crucial stage in software testing. It aims to incrementally integrate different software modules according to a certain logic to test the functionality of interfaces and interactions between these modules. A core issue in integration testing is determining the integration order, i.e., the test sequence. Software modules in object-oriented and aspect-oriented programming (AOP) systems often exhibit complex dependencies and interactions without a clear hierarchical structure, frequently presenting a network of dependencies and almost inevitably leading to dependency loops. This necessitates considering loop breaking and simulating certain dependencies when determining the integration order, i.e., constructing test stubs. Integration test sequence generation is essentially a multi-objective combinatorial optimization problem. Current integration test sequence generation methods almost entirely focus on finding the test sequence with the lowest testing cost, i.e., finding the integration test sequence with the fewest test stubs or the lowest test stub complexity. However, for a complex software system, the importance of different modules varies. For example, a module that interacts extensively with other modules can have severe consequences if it malfunctions. Due to limitations in testing resources or to improve testing efficiency, integration testing should prioritize integrating important modules, rather than solely considering the complexity of test stub simulation.
[0003] Currently, only graph theory-based test sequence generation methods consider the importance of software modules. These methods first perform network modeling of the software under test, then identify important nodes based on the software network model, and incorporate the importance of nodes into the weight calculation of loop edges. This ensures that the importance of nodes is inherently considered when deleting edges to break loops, and that high-importance nodes are placed at the beginning of the sequence as much as possible. This shows that finding important nodes from the perspective of the software network and incorporating them into test sequence generation is feasible and effective. However, these methods suffer from the common problems of graph theory methods, namely, high computational complexity when dealing with complex software, and the generated test sequences are almost unique, making it difficult to guarantee obtaining the optimal solution, especially when there is multiple objectives, and failing to provide a sufficient number of relatively optimal solutions for decision-making. Existing ensemble test sequence generation methods based on optimization algorithms only consider the testing cost objectives such as the method complexity and attribute complexity of test stub construction, without considering the different importance of different software modules. Summary of the Invention
[0004] The purpose of this invention is to provide a test sequence generation method based on the importance of network nodes to solve the above-mentioned problems.
[0005] The present invention solves the technical problem by adopting the following technical solution:
[0006] A method for generating test sequences based on the importance of network nodes includes the following steps:
[0007] Step 1: Collect the source code of the software under test and establish a software network based on the source code;
[0008] Step 2: Calculate the importance of network nodes from different perspectives to obtain the sequence of important nodes;
[0009] Step 3: Calculate the overall important node sequence;
[0010] Step 4: Design a fitness function that considers the importance of nodes;
[0011] Step 5: Design population aging factors;
[0012] Step 6: Generate test sequences using the rebirth multi-objective optimization algorithm.
[0013] Furthermore, the method for collecting the source code of the software under test and building a software network based on the source code in step 1 is as follows: obtain the source program file of the software to be tested, and then parse the software source code to obtain the software module set V = {v1, v2, ..., v...} n} and its logical relation set E = {e1,e2,…,e m A software module can be a software entity at different levels, such as a function, a class, or a method. A software network G is established based on this, where the network nodes in G are software modules and the edges are the interaction dependencies between modules.
[0014] Furthermore, the method for calculating the importance of network nodes from different perspectives and obtaining the sequence of important nodes in step 2 is as follows: Drawing on the method for calculating important nodes in complex network theory, degree centrality C is used respectively. D (v i ), betweenness centrality C B (v i Proximity centrality C C (v i ) and eigenvector centrality C E (v i The importance of each node in the software network is calculated using indicators such as C, C, etc.; then, each node in G is ranked according to its C... D (v i C B (v i C C (v i ) and C E (v i Sort the eigenvectors in descending order to obtain the sequence of eigenvector centrality important nodes and the sequence of eigenvector centrality important nodes, ImpSeq. DCImpSeq, a sequence of important nodes with betweenness centrality BC ImpSeq sequence of near-centrality important nodes CC ImpSeq, a sequence of important nodes with eigenvector centrality EC .
[0015] Furthermore, the method for constructing the comprehensive important node sequence described in step 3 is as follows: Calculate v for each node of network G. i The positions in each of the above sequences are denoted as follows: and Then calculate node v i Sorting and Finally, based on node v i Sorting and Sort all nodes in ascending order to obtain the comprehensive important node sequence ImpSeq of the software network.
[0016] Furthermore, the fitness function for considering node importance described in step 4 is constructed as follows: Assume any test sequence is TestOrder, with a sequence length consistent with ImpSeq, where n is the number of modules in the tested software and n is the number of nodes in the software network; firstly, the cosine similarity ImpCov(o) is used to measure the similarity between ImpSeq and TestOrder, also known as the coverage of important nodes; then, the cosine distance ImpDiff(o) is calculated to measure the difference between the test sequence and the comprehensive important node sequence, with a larger difference indicating a lower quality of the generated test sequence; the test complexity of the test sequence is calculated, using attribute complexity ACplx(o) and method complexity MCplx(o) to measure the test cost of the test sequence; the fitness function is then f fitness =[ImpDiff(o),ACplx(o),MCplx(o)], during the evolutionary generation of the test sequence, the evolutionary direction is to minimize f. fitness Each objective function in the equation; where o represents the test sequence.
[0017] Furthermore, the population aging factor described in step 5 is constructed as follows: Hypervolume (HV) is used to measure the quality of the generated test sequence set. For multi-objective optimization test sequence generation, the HV value will fluctuate slightly after the algorithm tends to converge. Assuming the current generation number is t, the HV value is HV. t The HV values of the population from generation t back 1 to Δt (i.e., t-1, ..., t-Δt) are respectively HV t-1 ,…,HV t-ΔtPopulation aging is defined as the situation where the HV value curve of the population from generation t-Δt to generation t no longer shows a significant increasing trend. The Mann-Kendall trend test is used to analyze the sequence [HV...] t-Δt ,…,HV t-1 HV t A trend test was performed to obtain the changing trend of the HV sequence and the corresponding p-value. Population aging occurred if and only if the trend was non-increasing and the p-value was less than 0.05; therefore, the aging factor q... aging The corresponding definition is the ratio of Δt to the maximum number of generations, which is used to determine the generation length Δt for judging population aging. Since populations generally do not experience aging in the early stages of evolution, and the aging judgment method is to judge by analyzing the changing trend of the population in generation Δt.
[0018] Furthermore, instead of performing an aging assessment at the outset, a starting point t is set. start As long as the number of generations exceeds t start Aging assessment is only conducted at certain times, and there is a t start ≥Δt.
[0019] Furthermore, the method for constructing the test sequence using the regeneration multi-objective optimization algorithm described in step 6 is as follows:
[0020] (1) Test sequence encoding: For a given software under test, all its modules are obtained through static analysis, and then the test sequence o is encoded using real number encoding;
[0021] (2) Define the crossover operator: Assume the crossover probability is r c For two individuals o1 and o2, randomly select n×r from o1. c There are n×r genes, and then find these n×r genes from o2. c The location of each gene is determined, and then the gene is copied to o1 in the same order as it appears in o2 to obtain a new individual.
[0022] (3) Define the mutation operator: For an individual o, randomly select two gene exchange sites; the mutation probability r m Used to determine the number of variant individuals in a population, assuming a population size of N. pop In a single mutation operation, N is selected. pop ×r m Perform mutation operations on each individual;
[0023] (4) Define the fitness function: with f fitness =[ImpDiff(o),ACplx(o),MCplx(o)] is the fitness function, and Pareto optimality is used to compare the performance of different individuals;
[0024] (5) Regeneration mechanism based on population aging: given the number of generations and aging factor q aging Next, the HV curve trend of the population within Δt generations is calculated to determine whether the population is aging. Once the population is aging, a new population is randomly generated to participate in evolution.
[0025] (6) Generate test sequences based on rebirth multi-objective optimization algorithm: Based on clarifying the key operations such as encoding, crossover mutation, fitness function and rebirth operation, integrate existing multi-objective optimization algorithms to generate test sequences. After the evolution is completed, the final population is output as the optimal solution, which is the final set of test sequences.
[0026] Beneficial effects:
[0027] The advantages of this invention compared to existing technologies are as follows: Existing software integration test sequence generation methods only employ a few graph theory methods that prioritize testing important software modules. However, these methods suffer from high computational complexity when dealing with complex software, and the generated test sequences are almost unique, making it difficult to guarantee optimal solutions. This invention overcomes the shortcomings of existing technologies by providing a test sequence generation method based on a rebirth multi-objective optimization algorithm. It constructs a test sequence generation method based on network node importance, designs a novel test coverage criterion (fitness function) based on important nodes in the software network and test costs, and applies it to the rebirth multi-objective optimization algorithm for test sequence generation. This ensures that the generated test sequences maximize the coverage of important nodes while minimizing test costs. This invention is applicable to solving the test sequence generation problem in practical software integration testing. It helps software testers design test sequences that meet requirements, reducing testing costs and improving testing efficiency while creating test sequences with higher software defect detection capabilities. It has high practical application value.
[0028] This invention aims to minimize coverage of critical nodes and reduce testing costs, generating multiple relatively optimal test sequences for decision-making. While achieving low testing costs, it prioritizes coverage of important software modules and optimizes test resource allocation. Attached Figure Description
[0029] Figure 1 This is a flowchart of the method of the present invention;
[0030] Figure 2 This is a schematic diagram of the crossover and mutation operators of the present invention;
[0031] Figure 3 This is a pseudocode diagram of the multi-objective optimization algorithm NNITO-NSGAII of the present invention. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0033] Existing software integration test sequence generation methods primarily focus on finding the test sequence with the lowest testing cost. However, for a complex software system, the importance of different modules varies. Due to limitations in testing resources or to improve testing efficiency, integration testing should prioritize the integration of important modules, rather than solely considering the complexity of test stub simulation. A very few graph theory methods address the issue of module importance, incorporating the importance of software modules into the weight calculation of loop edges, thus inherently considering node importance when deleting edges to break loops. However, such graph theory methods have high computational complexity when dealing with complex software, and the generated test sequences are almost unique, making it difficult to guarantee obtaining the optimal solution, especially when there is multiple objectives, and failing to provide a sufficient number of relatively optimal solutions for decision-making. Therefore, this invention overcomes the shortcomings of existing technologies by providing a test sequence generation method based on network node importance to solve the above problems. In this technology, software is modeled as a network, and important nodes of the software (i.e., functional entities of the software, such as functions, methods, classes, etc.) are discovered from the perspective of the network. Then, a test coverage criterion that considers the coverage of important nodes is proposed. The fitness function of generating test sequences based on optimization algorithms is used to minimize the coverage of important nodes and test costs. Test sequences are generated using a multi-objective optimization algorithm that includes a regeneration mechanism.
[0034] It can be seen that the construction of this technology integrates and innovates existing integrated test sequence generation methods and network node importance analysis methods based on optimization algorithms, forming a test sequence generation technology based on network node importance.
[0035] refer to Figure 1 This invention discloses a method for generating test orders based on network node importance. The method uses NNITO to describe the generation of test orders based on network node importance. It includes the following steps:
[0036] Step 1: Collect the source code of the software under test and build a software network based on the source code; the construction method is as follows:
[0037] First, obtain the source code files of the software to be tested. Starting from the software source code, based on the concept of reverse engineering, use static analysis tools such as Understand to analyze the software source code and obtain the software module set V = {v1, v2, ..., v...}. n} and its logical relation set E = {e1,e2,…,e m The text data here refers to software modules, which can be software entities at different levels such as functions, classes, and methods, usually determined by the software type. For example, in C language software, the functional entity is a function, which relies on function calls to achieve the expected function; therefore, its main software module is a function. After obtaining the data containing software modules and their logical relationships, the data is parsed, and modeling tools or software such as NetworkX are used to build a software network G. Depending on the selected modules, G can be a network of different granularities, such as a function call network, a class dependency network, or a method call network.
[0038] Step 2: Calculate the importance of network nodes from different perspectives to obtain the sequence of important nodes; the construction method is as follows:
[0039] Drawing on important node calculation methods in complex network theory, we adopt degree centrality C from a network perspective. D (v i ), betweenness centrality C B (v i Proximity centrality C C (v i ) and eigenvector centrality C E (v i The four most common node importance indices are used to calculate the importance of each node in the software network and determine the sequence of important nodes from different perspectives.
[0040] ① Degree centrality
[0041] Degree centrality is the most direct and common measure of node centrality in network analysis. It measures the degree to which a node in a network is connected to all other nodes. The higher the degree of a node, the higher its degree centrality, and the more important the node is in the network. For an undirected network G(V,E), node v i Degree centrality of node v i The total number of direct edges connecting node v to the other n-1 nodes. i The degree centrality is C D (v i Then we have:
[0042]
[0043] Sort each node in G in descending order of its degree centrality value to obtain the sequence ImpSeq of degree centrality important nodes. DC .
[0044] ② Betweenness centrality
[0045] Betweenness centrality is defined as the proportion of shortest paths passing through a given node in a network. The more shortest paths a node has, the more important it is. Let node v... i The betweenness centrality is C B (v i Then we have:
[0046]
[0047] in, Represents node v s to node v t The number of all shortest paths, Indicates from node v s to node v t The shortest path passes through node v i The number of nodes, summed, represents the sum of all nodes except node v. i Summing all possible pairs of nodes other than G. Sort each node in G in descending order of its betweenness centrality value to obtain the sequence ImpSeq, which is important nodes by betweenness centrality. BC .
[0048] ③ Closeness centrality
[0049] Closeness centrality is defined as the average of the shortest distances between a node and all other nodes in a network. It measures how close a node is to other nodes in the network. A higher closeness centrality value indicates that the node is more easily reached by other nodes. Let node v i The closeness centrality is C C (v i Then we have:
[0050]
[0051] Where, d ij Represents node v i to v j The shortest distance, summed, represents v. i The sum of the shortest distances to any node other than itself. Sort each node in G in descending order of its proximity centrality value to obtain the sequence ImpSeq, which represents important nodes with high proximity centrality. CC .
[0052] ④ Eigenvector centrality
[0053] Eigenvector centrality posits that the importance of a node depends both on the number of its neighbors and the importance of each neighbor; essentially, it measures the sum of the importance of a node's neighbors in a network. To calculate eigenvector centrality, the adjacency matrix A is first obtained. n×n Then calculate the eigenvectors of the adjacency matrix:
[0054] Ax=λx (4)
[0055] Where λ is the eigenvalue of network G, and x = [x1, x2, ..., x...]. n ] T Its feature vector, node v i Eigenvector centrality C E (v i The i-th element of the eigenvector x is denoted as . Similarly, each node in G is sorted in descending order according to its eigenvector centrality value, resulting in the eigenvector centrality important node sequence ImpSeq. EC .
[0056] Step 3: Calculate the comprehensive important node sequence. The construction method is as follows:
[0057] Degree centrality, betweenness centrality, proximity centrality, and eigenvector centrality are measures of node importance from different perspectives. To comprehensively evaluate node importance, the obtained ImpSeq sequence of these four important node types needs to be analyzed. DC ImpSeq BC ImpSeq CC and ImpSeq EC The fusion process is performed. The fusion method adopted in this invention is to calculate the value of each node v in network G. i The positions in each of the above sequences are denoted as follows: and Then calculate node v i Sorting and
[0058]
[0059] Finally, based on node v i Sorting and Sort all nodes in ascending order to obtain the comprehensive important node sequence ImpSeq of the software network.
[0060] Step 4: Design a fitness function that considers node importance. The construction method is as follows:
[0061] First, based on the obtained comprehensive important node sequence ImpSeq, we design the objective function of important node coverage. Assume any test sequence is represented as TestOrder, with a sequence length consistent with ImpSeq, and denoted by n, which is the number of modules in the tested software, i.e., the number of nodes in the software network. Cosine similarity is used to measure the similarity between ImpSeq and TestOrder, also known as important node coverage:
[0062]
[0063] In the formula, o represents the test sequence. When the test sequence TestOrder is completely consistent with the synthesis important node sequence ImpSeq, ImpCov(o) is 1. To achieve priority integration of important nodes, ImpCov(o) should be as large as possible. Since the goal of test cost is to minimize, cosine distance is used to transform ImpCov(o):
[0064] ImpDiff(o)=1-ImpCov(o) (3)
[0065] ImpDiff(o) represents the difference between the test sequence and the comprehensive important node sequence; a larger difference indicates a lower quality test sequence. From the perspective of important node coverage, ImpDiff(o) is one of the objective functions of this invention, and the goal during the evolutionary process is to minimize ImpDiff(o).
[0066] While considering coverage of important nodes, testing cost is also a crucial factor. This invention similarly uses method complexity and attribute complexity to measure the cost of a test sequence. Based on static analysis of the software under test, data on the software modules and their method coupling and attribute coupling are obtained and normalized. This yields the method complexity matrix M(v). i ,v j ) and attribute complexity matrix A(v i ,v j If module v i Depends on v j Then it is in M(v i ,v j ) and A(v i ,v j The value at the corresponding position is the corresponding complexity; otherwise, it is 0. For any test sequence o, we have:
[0067]
[0068]
[0069] In the formula, R stubThis represents all dependencies that need to be simulated in the test sequence o, i.e., test stubs. Thus, the three objective functions ImpDiff(o), ACplx(o), and MCplx(o) required by the multi-objective evolutionary algorithm of this invention are obtained, and therefore the fitness function f... fitness for:
[0070] f fitness =[ImpDiff(o),ACplx(o),MCplx(o)] (6)
[0071] During the evolutionary generation of the test sequence, the evolutionary direction is to minimize f. fitness Each objective function in
[0072] Step 5: Design population aging factors. The construction method is as follows:
[0073] This invention uses hypervolume (HV) to measure the quality of the generated test sequence set. For multi-objective optimization test sequence generation, the HV value will fluctuate slightly after the algorithm tends to converge. Assuming the current evolutionary generation is t, the HV value is HV. t The HV values for the population from generation t back 1 to Δt (i.e., generation t-1, ..., t-Δt) are respectively HV t-1 ,…,HV t-Δt This invention defines population aging as follows: from generation t-Δt to generation t, the HV value curve of the population no longer shows a significant increasing trend; therefore, population aging occurs. To this end, the Mann-Kendall trend test is used to analyze the sequence [HV...]. t-Δt ,…,HV t-1 HV t By performing a trend test to obtain the changing trend of the HV sequence and the corresponding p-value, we can conclude that:
[0074]
[0075] In the formula, 1 represents population aging, and 0 represents the opposite. Aging factor q aging This can be defined as the ratio of Δt to the maximum number of generations, used to determine the generation length Δt for judging population aging. Furthermore, since populations generally do not experience aging in the early stages of evolution, and the aging judgment method used in this invention is based on analyzing the changing trend of the population over generations Δt, this invention does not perform aging judgment at the beginning, but instead sets a starting point t. start As long as the number of generations exceeds t start Aging assessment is only conducted at certain times, and there is a t start ≥Δt.
[0076] Step 6: Generate test sequences using a rebirth multi-objective optimization algorithm. The construction method is as follows:
[0077] (1) Test sequence encoding: For a given software under test, all its modules are obtained through static analysis, and then the test sequence o is encoded using real number encoding, where each real number represents a software module, i.e. a gene;
[0078] (2) Define the crossover operator: Assume the crossover probability is r c For two individuals o1 and o2, randomly select n×r from o1. c There are n×r genes, and then find these n×r genes from o2. c The location of each gene is determined, and then the gene is copied to o1 in the same order as it appears in o2 to obtain a new individual.
[0079] (3) Define the mutation operator: For an individual o, randomly select two genes to exchange positions. The mutation probability r m In this invention, the role is to determine the number of mutated individuals in the population, assuming the population size is N. pop In a single mutation operation, N is selected. pop ×r m Each individual undergoes a mutation operation; the crossover and mutation operations of this invention are as follows: Figure 2 As shown;
[0080] (4) Define the fitness function: with f fitness =[ImpDiff(o),ACplx(o),MCplx(o)] is the fitness function, and Pareto optimality is used to compare the performance of different individuals;
[0081] (5) Regeneration mechanism based on population aging: given the number of generations and aging factor q aging Next, the HV curve trend of the population within Δt generations is calculated to determine whether the population is aging. Once the population is aging, a new population is randomly generated to participate in evolution.
[0082] (6) Generating Test Sequences Based on the Rebirth Multi-Objective Optimization Algorithm: Based on the key operations mentioned above, such as encoding, crossover mutation, fitness function, and rebirth, existing multi-objective optimization algorithms are integrated to generate test sequences. The final population after evolution is completed is output as the optimal solution, which is the final set of generated test sequences. The rebirth multi-objective optimization test sequence generation algorithm based on the NSGAII multi-objective optimization algorithm is as follows: Figure 3 As shown.
[0083] This invention, based on software network modeling, calculates the sequence of important software nodes from multiple perspectives and obtains a comprehensive sequence of important nodes. Then, it designs a fitness function considering important node coverage and testing cost. Finally, it treats test sequence generation as a multi-objective optimization problem and employs a regeneration multi-objective optimization algorithm to generate test sequences, ensuring that the generation of test sequences maximizes important node coverage while minimizing testing cost. This invention is applicable to solving the test sequence generation problem in the integration testing phase of practical software testing. It can help software testers design test sequences that meet requirements, reducing testing costs and improving testing efficiency while designing test data with higher software defect detection capabilities. This test data generation method combines complex network theory and multi-objective optimization test sequence generation methods to form a relatively practical test sequence generation method based on network node importance.
[0084] This invention provides a test sequence generation method based on network node importance. Based on software network modeling, this method calculates multiple importance levels for each node in the network, obtaining multiple important node sequences. Then, it calculates a comprehensive important node sequence and designs a test coverage criterion, i.e., a fitness function, based on important node coverage. Subsequently, a multi-objective optimization algorithm including a regeneration mechanism is employed to generate test sequences guided by important node coverage and minimizing test costs, ensuring that test sequence generation maximizes important node coverage while minimizing test costs. Using this technique allows for faster integration of important software modules into the generated test sequences, reducing testing costs and improving testing efficiency.
[0085] The advantages of this invention compared to existing technologies are as follows: Existing software integration test sequence generation methods only employ a few graph theory methods that prioritize testing important software modules. However, these methods suffer from high computational complexity when dealing with complex software, and the generated test sequences are almost unique, making it difficult to guarantee optimal solutions. This invention overcomes the shortcomings of existing technologies by providing a test sequence generation method based on a rebirth multi-objective optimization algorithm. It constructs a test sequence generation method based on network node importance, designs a novel test coverage criterion (fitness function) based on important nodes in the software network and test costs, and applies it to the rebirth multi-objective optimization algorithm for test sequence generation. This ensures that the generated test sequences maximize the coverage of important nodes while minimizing test costs. This invention is applicable to solving the test sequence generation problem in practical software integration testing. It helps software testers design test sequences that meet requirements, reducing testing costs and improving testing efficiency while creating test sequences with higher software defect detection capabilities. It has high practical application value.
[0086] This invention aims to minimize coverage of critical nodes and reduce testing costs, generating multiple relatively optimal test sequences for decision-making. While achieving low testing costs, it prioritizes coverage of important software modules and optimizes test resource allocation.
[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating test sequences based on the importance of network nodes, characterized in that, Includes the following steps: Step 1: Collect the source code of the software under test and establish a software network based on the source code; Step 2: Calculate the importance of network nodes from different perspectives to obtain the sequence of important nodes; Step 3: Calculate the overall important node sequence; Step 4: Design a fitness function that considers the importance of nodes; Step 5: Design population aging factors; Step 6: Generate test sequences using the rebirth multi-objective optimization algorithm; The fitness function that considers node importance as described in step 4 is constructed as follows: Assume any test sequence is... TestOrder Sequence length and ImpSeq Consistency refers to the number of modules in the tested software and the number of nodes in the software network. n First, cosine similarity is used. ImpCov ( o )measure ImpSeq and TestOrder The similarity is also called the coverage of important nodes, and then the cosine distance is calculated. ImpDiff ( o This is used to measure the difference between the test sequence and the comprehensive important node sequence; the larger the difference, the worse the quality of the generated test sequence. Calculate the test sequence complexity using attribute complexity. ACplx ( o and method complexity MCplx ( o The fitness function measures the testing cost of the test sequence; the fitness function is... In the process of generating test sequences through evolution, the evolutionary direction is minimization. f fitness Each objective function in; where o Represents the test sequence; The test sequence generated in step 6 using the regeneration multi-objective optimization algorithm is constructed as follows: (1) Test sequence encoding: For a given software under test, all its modules are obtained through static analysis, and then real number encoding is used to encode the test sequence. o coding; (2) Define the crossover operator: Assume the crossover probability is r c For two individuals o 1 and o 2 Random selection o 1 In One gene, then from o 2 Find this The location of each gene, and then according to its position o 2 Copy it to the order in the file. o 1 Go through it and obtain a new individual; (3) Define the mutation operator: for individuals o Two genes are randomly selected for exchange; mutation probability. r m Used to determine the number of variant individuals in a population, assuming the population size is . N pop Then, in a single mutation operation, select Perform mutation operations on each individual; (4) Define the fitness function: The fitness function is used, and Pareto optimality is employed to compare the performance of different individuals. (5) Regeneration mechanism based on population aging: under a given number of evolutionary generations and aging factor q aging Next, calculate The HV curve trend of the population within a generation is used to determine whether the population is aging. Once the population ages, a new population is randomly generated to participate in evolution. (6) Generate test sequences based on rebirth multi-objective optimization algorithm: Based on the above coding, crossover mutation, fitness function and rebirth operation, integrate existing multi-objective optimization algorithms to generate test sequences. After the evolution is completed, the final population is output as the optimal solution, which is the final set of test sequences generated.
2. The method for generating test sequences based on network node importance according to claim 1, characterized in that, The method for collecting the source code of the software under test and building a software network based on the source code in step 1 is as follows: obtain the source program files of the software to be tested, and then parse the software source code to obtain a set of software modules. and its logical relationship set To establish a software network G ,but G In the network, nodes represent software modules, and edges represent the interaction dependencies between modules.
3. The method for generating test sequences based on network node importance according to claim 2, characterized in that, Step 2, which calculates the importance of network nodes from different perspectives to obtain the sequence of important nodes, is constructed as follows: Drawing on the methods for calculating important nodes in complex network theory, degree centrality is used respectively. Betweenness centrality Proximity centrality and eigenvector centrality As a node importance indicator, the importance of each node in the software network is calculated; then, respectively... G Each node in the middle according to its , , and Sort the values in descending order to obtain the sequence of eigenvector centrality important nodes and the sequence of degree centrality important nodes. Betweenness centrality important node sequence Sequences of near-centrality important nodes eigenvector centrality important node sequence .
4. The method for generating test sequences based on network node importance according to claim 3, characterized in that, The method for constructing the computational synthesis of the important node sequence described in step 3 is as follows: computational network G Each node The positions in each of the above sequences are denoted as follows: , , and Then calculate the nodes. Sorting and Finally, based on the nodes Sorting and Sort all nodes in ascending order to obtain the comprehensive important node sequence of the software network. ImpSeq .
5. The method for generating test sequences based on network node importance according to claim 4, characterized in that, The design of the population aging factor described in step 5 is constructed as follows: The quality of the generated test sequence set is measured using the hypervolume (HV). For multi-objective optimization test sequence generation, the HV value will fluctuate slightly after the algorithm converges. Assume the current generation number is... t HV value HV t , t Go back 1 to The HV values corresponding to each generation are as follows: Population aging is defined as the process from the first generation to the last generation. to t If the HV value curve of a generation no longer shows a significant increasing trend, then the population is aging. The Mann-Kendall trend test was used to analyze the series. Perform trend analysis to obtain the changing trend of the HV sequence and the corresponding... p A value is given if and only if the trend is a non-incremental trend, and p When the value is less than 0.05, the population is aging; therefore, the aging factor... q aging The corresponding definition is The ratio to the maximum number of generations is used to determine the generation length for judging population aging. Since populations generally do not age in the early stages of evolution, and the method used to determine aging is through analysis... Judging from the changing trends of the population.
6. The method for generating test sequences based on network node importance according to claim 5, characterized in that, Instead of performing an aging assessment at the beginning, a starting point is set. t start As long as the number of generations exceeds t start Aging assessment is only conducted at certain times, and there are .
Citation Information
Patent Citations
Software test data generation method based on software network
CN114020647A