CN110399285B - Test case reduction method based on weak mutation analysis - Google Patents

Test case reduction method based on weak mutation analysis Download PDF

Info

Publication number
CN110399285B
CN110399285B CN201810372296.8A CN201810372296A CN110399285B CN 110399285 B CN110399285 B CN 110399285B CN 201810372296 A CN201810372296 A CN 201810372296A CN 110399285 B CN110399285 B CN 110399285B
Authority
CN
China
Prior art keywords
variant
matrix
branch
test case
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810372296.8A
Other languages
Chinese (zh)
Other versions
CN110399285A (en
Inventor
王曙燕
袁佳娟
孙家泽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian University of Posts and Telecommunications
Original Assignee
Xian University of Posts and Telecommunications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian University of Posts and Telecommunications filed Critical Xian University of Posts and Telecommunications
Priority to CN201810372296.8A priority Critical patent/CN110399285B/en
Publication of CN110399285A publication Critical patent/CN110399285A/en
Application granted granted Critical
Publication of CN110399285B publication Critical patent/CN110399285B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/004Artificial life, i.e. computing arrangements simulating life
    • G06N3/006Artificial life, i.e. computing arrangements simulating life based on simulated virtual individual or collective life forms, e.g. social simulations or particle swarm optimisation [PSO]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Biomedical Technology (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Complex Calculations (AREA)

Abstract

The invention provides a test case reduction method based on weak mutation analysis, which is used for reducing invalid test cases under the condition of keeping the sufficiency of the test cases basically unchanged. The method comprises the following steps: constructing a variation branch, inserting an original program to generate a new program, and executing an original test case set to generate a binary relation matrix of the test cases and the variation branch; grouping matrix columns and reducing invalid variants after coding; obtaining a test case corresponding to the test case coverage variation branch subset and reducing; and obtaining the reduced effective test case set by the simplified relation matrix through an artificial fish swarm algorithm. The method analyzes the coverage conditions of the test cases and the variant branches based on a weak variant criterion, and effectively reduces the test cases under the condition of not changing or extremely changing the variant score, and relates to the technical field of software.

Description

Test case reduction method based on weak mutation analysis
Technical Field
The invention belongs to the technical field of software testing, in particular to the field of mutation testing, analyzes the coverage relation between a test case and a mutation branch based on a weak mutation criterion, and is a test case reduction method based on weak mutation analysis.
Background
Software testing is an important means for ensuring software quality, in gradual and rapid iterative development, continuous release of new versions makes testing more frequent, and in an extreme programming method, testing is required to be performed several times every day. With the increase of software complexity, the scale of the test cases is increased, the given test requirements are met by using as few test cases as possible, the test efficiency can be greatly improved, and the test cost is reduced. The mutation test is a software test technology based on defects, and can evaluate the software quality and the sufficiency of test cases.
The existing research on the mutation test mainly comprises mutation object selection, variant selection and reduction and test case reduction, in the past decades, the research on the mutation test mainly focuses on the selection and reduction of variants, and the sampling method, the variant operator selection and the statistical optimization method are adopted to select and reduce the variants, but the evaluation on the software quality and the test fullness is possibly influenced. Meanwhile, the mutation test judges whether the variant is killed or not, and has a strong mutation test and a weak mutation test. The test case is required to be capable of being executed to a mutation statement, the state of the program is changed after the mutation statement is executed, the changed result can influence the output of the program, and the test case which meets 2 conditions of accessibility and necessity is a weak mutation test. Whether the original program P is identical to the variant M or not is judged through a strong variation test, whether the variant is killed or not is judged, a large number of variants are generated in the variation test, so that the variation test efficiency is greatly reduced, strong variation can be effectively replaced by weak variation, the variant is converted into a variation branch based on the weak variation criterion, the statement s in the original program P is varied, the variants can be converted into the if (s = s ') variation branch of the structure of the original statement s and the variation statement s ' one by one based on the weak variation criterion, the converted variation branch is inserted into the corresponding position of the P to form a new program P ', and most of the existing variation tests are executed under the strong variation criterion, so that the cost of the variation test is increased.
Therefore, a test case and a variant branch relation matrix are generated based on the weak variant criterion, the invalid variant and the subset test case are reduced to obtain a simplified matrix, and a more complete and effective test case set is obtained by combining an algorithm.
Disclosure of Invention
A test case reduction method based on weak mutation analysis obtains a test case and a mutation branch relation matrix through mutation branch transformation, covers the test case with reduction variants and subsets, and obtains the reduced test case by combining an artificial fish swarm algorithm. The method is characterized by mainly comprising the following steps:
(1) Generating a test case and a variant branch relation matrix based on weak variant transformation: generating n variants M = { M) for the original program P using the mutation testing tool Mujava 1 ,m 2 ,m 3 ........m n And constructing a corresponding variant branch B = { B ] by combining a log file mutation _ log 1 ,b 2 ,b 3 ,...,b n Inserting the mutation branch B into a position corresponding to the mutation point P to form a new program P', and assuming that m original test case sets T = { T = T } 1 ,t 2 ,t 3 ,.....t m Executing P' by using T to generate a test case variation branch relation two-dimensional matrix MT (m+1)×(n+1)
Figure BDA0001638860900000011
Wherein the 0 th row MT in the matrix row0 ={mt 01 ,mt 02 ,...,mt 0n Denotes the mutation branch number (No operation is done in the 0 th row and the 0 th column below), and the 0 th column MT in the matrix col0 ={mt 10 ,mt 20 ,...,mt m0 Denotes a test case number. If test case t i ,i∈[1,m]Can cover variant branches b j ,j∈[1,n]If yes, then remember mt ij =1, otherwise, register mt ij =0;
(2) Reduction of equivalent variants: for the MT in the step (1) (m+1)×(n+1) The matrix, considering the great number of variants, the great complexity of time for directly solving equivalent variants with operations and the difficulty of binary coding brought by the increase of the number of test cases, will MT (m+1)×(n+1) Grouped by rows first
Figure BDA0001638860900000021
Group, where l is the custom packet length. After grouping, taking the column in each group as binary code to obtain corresponding value V g ={v g1 ,v g2 ,v g3 ,...,v gn },g∈[1,G]The g-th group and j-th column have binary codes corresponding to values of
Figure BDA0001638860900000022
j∈[1,n]Therefore to the whole MT (m+1)×(n+1) Binary coding of the matrix corresponds to a value V = { V = } 1 ,v 2 ,v 3 ,...,v n },
Figure BDA0001638860900000023
According to the column reduction of the V pair matrix, the following three cases are divided:
(a) If v is j =0, the variant corresponding to the variant branch is the equivalent variant of weak variant analysis, and the j column of the matrix is recorded and deleted;
(b) If it is
Figure BDA0001638860900000024
All the test cases can kill the variant, so that the variant branch is a test case full-coverage variant branch, the variant corresponding to the variant branch is reduced, and the jth column of the matrix is deleted;
(c) In addition to the two cases described above, if v j =v k Equal (j is more than or equal to 1 and less than or equal to k and less than or equal to n), and v in the group is checked gj And v gk If so, indicating that variant branches corresponding to the jth column and the kth column have the same branch coverage condition, deleting variants corresponding to the variant branches of the kth column, and deleting the kth column of the matrix; matrix MT obtained by reducing equivalent variants (m+1)×r ,r∈[0,n];
(3) Subset test case reduction: the reduction of the test cases of the subset represents the reduction of the test cases corresponding to the variant branch subset, and can be divided into the following parts:
(a) For MT (m+1)×r Matrix statistics of variant branch coverage C = { C) per row 1 ,c 2 ,c 3 ...,c m Coverage of variant branches in row i
Figure BDA0001638860900000025
i∈[1,m];
(b) Selecting the maximum value C of C i ,i∈[1,m]Marking the ith row as visited, recording the column index set S = { S } corresponding to the element of the ith row 0 1 ,s 2 ,s 3 ....s h },h∈[1,r]If the ith 'row, i' is E [1,m]If all columns in S are 0, t is the same i' Variable branches that can be covered, t i Must cover, i.e. t i' Is t i Mutating the subset covered by the branches, thus deleting the matrix MT (m+1)×r And C in C i And c i' Deleting, traversing all non-visited rows in the matrix, deleting the matrix MT (m+1)×r Middle t i The row corresponding to all subsets covered by the variation branch, and deleting the variation branch coverage of the row corresponding to all subsets in the C, repeating the step 3 (b) until the C set is empty;
(c) Matrix MT obtained by reduction of test case s×r ,s∈[0,m]And (3) obtaining a matrix MT after the equivalent variant reduction in the step (2) s×t ,t∈[0,r];
(4) Reduction of test case: aiming at the matrix MT obtained in the step (3) s×t Due to MT s×t The matrix is a reduced matrix, at least one branch in each column covers, so the maximum variation branch number Tc = t-1 of the whole matrix, and therefore the ideal covering branch Ic =1111 s×t Each row of the matrix is regarded as a test case binary code and stored in B = { B = { (B) } 1 ,b 2 ,b 3 ,...,b s-1 Like b 1 =mt 11 mt 12 mt 13 ....mt 1(t-1) The binary system of the test case variant branch cover and the ideal variant branch cover after bitwise AND operation is taken as the actual cover, namely R x =b x &Ic,x∈[1,s-1]Then, the approximation degree of each test case to the ideal variant branch is counted, and is expressed as f' (x) = count (R) x ),count(R x ) Is R x The sum of the number of 1's in the represented binary system, so that the variant branch with the maximum approximation degree of the current ideal variant branch is covered with the corresponding test branchExample is the current optimal solution: f (x) = max (f' (x)), the test data set reduced in the step (3) is used as input, an artificial fish swarm algorithm is applied to the test case binary code B, iteration is carried out, the test case which can cover the ideal variation branch most is searched, and the step (4) is repeated until the test data set covering the maximum branch coverage is generated or the maximum iteration number is reached.
Has the advantages that:
the corresponding relation between the test cases and the variants can be effectively obtained and stored in a binary matrix by executing a new program for constructing the variant branches once based on a weak variant criterion, the invalid variants and the subset test cases are reduced by analyzing the relation between the test cases and the variants, and the test case set with better coverage rate is obtained according to a matrix combination algorithm, so that a more complete and effective test case set can be obtained. The practice of the invention will now be illustrated by specific examples.
(1) Test object
When an experimental object is selected, J1 and J2 are common benchmark test programs, J3 is from a Siemens program set, and the programs are widely applied to verifying the effectiveness of different test methods and belong to classical experimental programs.
(2) Assessment standard test
The invention aims to more effectively reduce the test cases through a weak variation criterion, so that the effectiveness, the sufficiency and the accuracy of the method are selected as the measuring standards. The effectiveness is measured by comparing the number of test cases and variants before and after reduction and by the reduction rate of the coverage of different variant branches, and meanwhile, the method is compared with a greedy algorithm commonly used for reduction of test cases in terms of reduction rate, variation scoring and time consumption; verifying the sufficiency of the test cases, namely obtaining the test cases with different variant branch coverage degrees, and comparing the variant scores before reduction to obtain whether the sufficiency of the test cases after reduction is unchanged or slightly reduced; the accuracy of the method is judged by the equivalence variant correctness identification through the equivalence variant obtained under strong variation and the equivalence variant identified by the structural variation branch under weak variation criterion, and the recall ratio and the precision ratio. The experiment aims to reduce invalid test cases on the premise of not changing or extremely changing the variation score, so that the reduced test case set has the minimum influence on the test coverage rate.
(3) Experimental implementation
The method comprises the steps of recording the number of original test cases and variants, equivalent variants and variant scores, obtaining the number of test cases and variants with different variant branch coverage rates and the number of equivalent variants through the method, analyzing the obtained reduction rate of the test cases and variants and the recall rate and precision rate of the equivalent variants, and obtaining relevant data through combination with a greedy algorithm to compare and analyze the relevant data with the method.
The set algorithm has better experimental results through a large number of experiments, and the parameters of the artificial fish school algorithm are as follows: initial population number fishernum =5, step length =1, crowdedness factor delta =0.2, visual field range =2, and maximum trial number tryNumber =5 for each foraging.
(4) Analysis of results
Comparing the results of the method and the greedy algorithm under different variation branch coverage rates and equivalent variants obtained under strong and weak variation criteria by comparing 3 programs of J1-J3, the following results are specifically analyzed as follows:
TABLE 1 basic information of raw data
Figure BDA0001638860900000041
Table 1 shows basic information of the test program, including information of variant operator type, variant number, original test case number, and the like.
TABLE 2 comparison of variants and test cases before and after reduction
Figure BDA0001638860900000042
Note: number of test cases before BT-reduction AT-number of test cases after reduction BM-number of variants before reduction AM-number of variants after reduction AM
From table 2, it can be analyzed that the larger the coverage of the variant branches (the following coverage of the variant branches are the coverage of the variant branches of the matrix after simplification under the method), the smaller the reduction rate, but the minimum reduction rate is not less than 57.1%, the maximum reduction rate is 90.1%, and the average reduction rate is 79.01%; the reduction rate of the mutant was about 59.1% at the minimum, 71.4% at the maximum, and 64.9% on average.
TABLE 3 variation scores after reduction
Figure BDA0001638860900000043
The larger the coverage rate of the variant branches is, the higher the variant score is, as shown in table 3, and as shown in table 2, the variant score is the same as the original test case score when the reduction rates of J1 and J2 are 70% and 57.1%, respectively, under the condition that the variant branches cover 100%; j3 with 100% coverage of variant branches, the reduction rate was about 70.5% and the variant score was 1% less than the original test case.
Comparison of recognition of equivalent variants under 4 Strong and Weak variants
Figure BDA0001638860900000044
The equivalent variant identification under the weak variation criterion can be compared with the equivalent variant identification under the strong variation by analyzing in table 4, the recall ratio can reach 80 percent at most and 71.4 percent at least, and the equivalent variants identified under the weak variation are all equivalent variants which can not be killed under the strong variation.
TABLE 5 comparison of reduction rate and variance score for greedy algorithm versus present method when variance branch coverage is 100% and 80% coverage
Figure BDA0001638860900000051
From the analysis in table 5, when the coverage of the variant branches is 80%, the reduction rates of the method in this chapter are all greater than or equal to those of the greedy algorithm, but the variation scores of J2 and J3 are less than those of the greedy algorithm, that is, when the coverage of the variant branches is 80%, the reduction rate is excessively pursued and the variation score is reduced, but when the coverage of the variant branches is 100%, the maximum reduction rate of the algorithm in this chapter is 70.58%, and the minimum reduction rate is 57.1%, and the maximum reduction rate of the greedy algorithm is 60%, and the minimum reduction rate is 5.88%, and the variation scores are the same, so that the test case can be better reduced and the sufficiency of the test case can be ensured when the coverage of the variant branches is 100%, and the greedy algorithm is usually applied to the reduction of the test case, so the greedy algorithm is selected to compare with the method.
Because the artificial fish swarm algorithm can randomly generate an initial position, different results can be generated by multiple operations, and the above experimental result is a one-time operation result under corresponding conditions.
The invention aims to obtain a more effective test case set based on a weak variation criterion, so that the effectiveness, the sufficiency and the accuracy of the method are selected as the measuring standards. The effectiveness can be measured by comparing the number of test cases and variants before and after reduction and obtaining reduction rate through different variation branch coverage degrees, and meanwhile, the method is compared with a greedy algorithm commonly used for reduction of test cases in terms of reduction rate, variation scoring and time consumption; verifying the sufficiency of the test cases by obtaining the test cases with different variation branch coverage degrees and comparing whether the sufficiency of the variation scoring test cases of the test case set is unchanged or slightly reduced before and after reduction; the accuracy of the method is judged by the equivalence variant correctness identification through the equivalence variant obtained under strong variation and the equivalence variant identified by the structural variation branch under weak variation criterion, and the recall ratio and the precision ratio. The experiment aims to effectively reduce the variant and the test case on the premise of not changing or extremely changing the variation score, so that the reduced test case has the minimum influence on the test coverage rate.
The comprehensive experimental data shows that the test cases can be effectively reduced under the condition of not changing or slightly changing the variation scores; the precision ratio of the method for identifying the equivalent variants under strong variation can reach 100 percent; the comparison greedy algorithm can effectively reduce the test cases while reducing the variants.
Drawings
FIG. 1 is a flow chart of functional module design according to the present invention.
Fig. 2 is a diagram of an example program, media.
FIG. 3 is a diagram of mutation branches constructed after an example program is subjected to the ROR mutation operator in accordance with the present invention.
FIG. 4 shows the new procedure after the insertion of variant branches according to the present invention.
Detailed Description
As shown in FIG. 1, the invention combines the artificial fish swarm algorithm based on the weak mutation criterion, and obtains an effective test case set under the condition of not influencing or slightly influencing the mutation score. Java, an example of an example program, is as follows:
(1) Generating a test case and variant relation matrix based on weak mutation transformation: the operation of mutation is performed on the exemplary program of fig. 2 by using a Mujava mutation test tool, fig. 3 is a mutation branch constructed after an ROR mutation operator is performed on the exemplary program, and fig. 4 is a new program obtained by inserting the mutation branch into a corresponding position of a mutation point of an original program. Selecting 5 mutation operators of AOIU, AOIS, ROR, COI and LOI to generate 132 variants, converting all the variants into variant branches, inserting the variant branches into the original program to generate a new program, executing the original 42 test cases to generate MT 42×133 Matrix:
Figure BDA0001638860900000061
if test case t i ,i∈[1,42]Can cover variant branches b j ,j∈[1,132]Then register mt ij =1, otherwise, register mt ij =0; the resulting matrix is as follows:
Figure BDA0001638860900000062
(2) Equivalent variants are reduced, and the code for each column is as follows:
code of column 1 is v col1 =11 1111111111 1111111111 1111111111 1111111111,
Code of column 2 is v col2 =11 1111111111 1111111111 1111111111 1111111111,
Code of column 3 is v col3 =00 0000000001 0011000100 0000000000 0000000000,
Column 132 code v col(132) =11 1111111111 1111111111 1111111111 1111111111。
For matrix MT 42×133 Grouping, each group being given a length l of 10, since
Figure BDA0001638860900000063
The original program matrix is divided into 5 groups:
coding value V of each column element in group 1 1 ={v 11 ,v 12 ,v 13 ,...,v 1(132) }={1111111111,1111111111,0000000000,...,1111111111}={1023,1023,0,...,1023},
Coding value V of each column element in group 2 2 ={v 21 ,v 22 ,v 23 ,...,v 2(132) }={1111111111,1111111111,0000000000,...,1111111111}={1023,1023,0,...,1023},
Coding value V of each column element in group 3 3 ={v 31 ,v 32 ,v 33 ,...,v 3(132) }={1111111111,1111111111,0011000100,...,1111111111}={1023,1023,196,...,1023},
Coding value V of each column element in group 4 4 ={v 41 ,v 42 ,v 43 ,...,v 4(132) }={1111111111,1111111111,0000000001,...,1111111111}={1023,1023,1,...,1023},
Coding value V of each column element in group 5 5 ={v 51 ,v 52 ,v 53 ,...,v 5(132) }={0000000011,0000000011,0000000000,...,0000000011}={3,3,0,...,3}。
Adding the numerical values of each group of corresponding columns to obtain the grouped codes of each column of the whole matrix:
V={v 1 ,v 2 ,v 3 ,...,v n }
={v 11 +v 21 +v 31 +v 41 +v 51 ,v 12 +v 22 +v 32 +v 42 +v 52 ,v 13 +v 23 +v 33 +v 43 +v 53 ,...v 1n +v 2n +v 3n +v 4n +v 5n }
={1023+1023+1023+1023+3,1023+1023+1023+1023+3,0+0+196+1+0,...,1023+1023+1023+1023+3}
={4095,4095,197,...,4095}
value pair MT according to V 42×133 Doing the following operation, wherein j ∈ [1,n]:
(a) If v is j Is 0, the jth column of the matrix is recorded and deleted;
(b) Since m% l is not equal to 0, if
Figure BDA0001638860900000071
Deleting the jth column of the matrix;
(c) Except for v j If v is 0 or other than 4095 j Value of (a) and v k Equal (j is more than or equal to 1 and less than or equal to k and less than or equal to n), and v in the group is checked gj And v gk ,g∈[1,5]If yes, deleting the k column of the matrix;
according to the number V, about 77 variant branches are reduced, corresponding to 77 null variants, and the reduced variant branches are numbered as follows:
{1,2,5,6,7,8,9,10,13,14,15,16,17,18,20,21,22,25,26,27,28,29,30,32,33,34,37,38,39,40,41,42,44,45,46,47,49,50,51,52,53,54,56,57,58,59,60,78,79,85,86,90,92,93,97,98,100,104,105,106,107,111,112,113,114,115,116,117,118,121,122,125,127,128,130,131,132}
matrix MT obtained after reduction 42×55 The following are:
Figure BDA0001638860900000072
(3) Subset test case reduction: for MT 42×55 Obtaining the corresponding variant branch coverage C = { C) by the reduced variant branch corresponding to each test case in the matrix 1 ,c 2 ,c 3 ...,c 42 } = {13,17,12 29 Corresponding coverage is 19 max, mark this line as visited, record t 29 Uncovered set of variant branch indices I, i.e. MT 42×55 A column index set I = {3,4,11.,. 129} corresponding to 0 element in a row with the 0 th column 29 in the matrix, in order to find a test case corresponding to a variant branch subset variant branch which can be covered by a current test case, traversing unmarked rows in the matrix, not finding a test case corresponding to a subset branch thereof, and deleting t elements in the matrix 29 Corresponding row, delete C in C set 29 Continuously finding the test case with the maximum coverage in the C set, wherein when the maximum coverage is 16, the test case is t 14 Marking this line as accessed, record t 14 The uncovered variant branch index set I = {3,4,11.. Multidot.124 }, the 0 th column is a 34 th row, which corresponds to all column indices in the set I being 0, so t 34 Variant branches t that can be covered 14 T in the matrix can be covered and deleted definitely 34 Corresponding row, delete C in C set 14 And c 34 And continuously finding the C set with the maximum coverage, and repeating the operation until the C set is empty. The test cases for the reduction are:
{t 11 ,t 12 ,t 20 ,t 21 ,t 22 ,t 28 ,t 31 ,t 32 ,t 33 ,t 34 ,t 35 ,t 36 ,t 37 ,t 38 ,t 39 ,t 40 ,t 41 ,t 42 }
resulting matrix MT of reduction test cases 24×55 Comprises the following steps:
Figure BDA0001638860900000081
further processing the matrix obtained by the reduction of the variant in step (2)MT as follows 24×54
Figure BDA0001638860900000082
(4) Reducing the test case based on the artificial fish swarm algorithm: for MT 24×54 Matrix, total mutation branch covering number Tc = t-1=53, initializing ideal mutation branch
Figure BDA0001638860900000083
Will MT 24×54 Each row of the matrix (except row 0) is stored as test case binary code:
B={b 1 ,b 2 ,b 3 ,...,b 27 ,b 29 ,b 30 }
={0100...0000,0000...1000,0100...0000,...,1010...0000,0000...0100,0000...0000}
the specific steps of combining the artificial fish swarm algorithm are as follows:
(a) The status of each artificial fish can be represented as a vector X = (X) 1 ,x 2 ,x 3 ,.....,x n ),i∈[1,n]The food concentration at the position of each artificial fish Y = f (X), wherein Y is the value of the objective function; initializing parameters, wherein the initial population number fishernum =5, the Step length Step =1, the crowdedness factor delta =0.2, the visual field range visual =2, the maximum trial number tryNumber =5 for each foraging and the distance d between the artificial fish individuals i and j i,j =||X i -X j ||。
(b) Starting to randomly generate an initial population where the state of the artificial fish maps to the row number in the matrix (except row 0), and the randomly generated 5 bits are { X } 1 =3,X 2 =7,X 3 =26,X 4 =9,X 5 =12}, calculating an adaptive value of each position, wherein the adaptive value is a binary code corresponding to the row number (calculated from 0) of the current position and a binary code covered by an ideal branch according to the bitwise AND operation, and counting the number of times of 1 occurrence in the result, namely R 3 =b 3 &Ic =010.. 0000, and then counting each test case against ideal variationThe degree of approximation of the branch is represented by f' (x) = count (R) x ),=count(R 3 ) =12, the test case corresponding to the variant branch with the maximum approximation of the current ideal variant branch is covered as the current optimal solution: f (x) = max (f' (x)), behavior selection is performed by the following three behaviors:
1) Foraging behavior
An artificial fish X, a behavior of fish swimming along a direction of a lot of food i Randomly selecting a state X within its field of view j Calculating their objective function values respectively and comparing them, if Y is found j Ratio Y i Preferably, then X i To X j The direction of (1) is moved by one step; otherwise, X i Continue to select state X within its field of view j Judging whether the forward condition is met or not, if the forward condition is not met after repeated try of trynumber times, randomly moving one step to enable X i A new state is reached. The expression is as follows:
when Y is i <Y j The method comprises the following steps:
Figure BDA0001638860900000091
when Y is i ≥Y j The method comprises the following steps:
X inext =X i +Rand()×Step
in the formula X inext Represents the position of the next step of the artificial fish, and Rand () represents [0,1 ]]A random number in between.
2) Cluster behavior
The fishes are gathered into groups in order to ensure the survival of the fishes and avoid harming the nature in the course of swimming. The rules followed when fish are clustered are three: the separation rule is as follows: avoid overcrowding with the neighboring partner as much as possible; alignment rules: as much as possible in line with the average direction of neighboring partners; cohesion rule: trying to move towards the centre of the nearby partner. X i For the current state of the target artificial fish, the neighborhood internal partner number set K is defined as follows:
K={X j |X j -X i ≤visual},i,j=1,2,3,....,n
if the set K is not empty, the situation that an active artificial fish individual exists in the visual field range of the current artificial fish is indicated, and the number n of partners in the visual field range of the current artificial fish is determined f Searching for center position X by the following formula and not less than 1 c
Figure BDA0001638860900000092
If Y is c /n f >δY i Indicating that the buddy center position status is better and less crowded, X i Towards the centre position X of the partner c Moving by one Step, the expression is as follows:
Figure BDA0001638860900000093
if the condition is not met, the foraging behavior is continuously executed.
3) Behavior of rear-end collision
X i For the current state of the target artificial fish, X i Searching for the optimal partner X among all partners in the visual field max If Y is max /n f >δY i Indicating less crowding around the optimal partner, X i Moving one Step towards the optimal partner, the expression is as follows:
Figure BDA0001638860900000101
otherwise, foraging behavior is executed.
4) Random behavior
The random behavior of the artificial fish is actually a default behavior of foraging behavior, and the activity rule is that the next state is randomly selected in the visual field range and is moved to the state by a Step length Step.
(c) Behavior selection
And selecting the behavior with the maximum advancing amplitude towards the optimal direction in the current state. The method is a trial and error method, namely, random, rear-end collision, clustering and foraging behaviors which may be executed by the artificial fish are simulated, the behaviors of the artificial fish are selected according to the specific situation of the current problem and the environment of the artificial fish, and the optimal behavior is selected through data generated after the behaviors are executed.
(d) Bulletin board
The bulletin board is used for recording the states of the artificial fishes, each artificial fish compares the current state of the artificial fish with the state recorded in the bulletin board after executing iteration for one time, if the current state is superior to the state in the bulletin board, the state in the bulletin board is updated by using the state of the artificial fish, and otherwise, the state of the bulletin board is unchanged. And when the iteration of the whole algorithm is finished, outputting the bulletin board value which is the optimal value.
Artificial fishes in the population are selected by foraging, gathering, following and random, and the value on the bulletin board is updated to be the maximum value of the global fitness value. Iterating foraging, searching the test cases which can cover the most ideal variation branches until generating a test data set covered by the maximum branches or reaching the maximum iteration times, and finally obtaining the positions as follows:
{2,1,5,4,9,3,6,7,8,13,14,10,15,17,23,18,24,27}
the final reduced test case set is therefore:
{t 2 ,t 1 ,t 5 ,t 4 ,t 9 ,t 3 ,t 6 ,t 7 ,t 8 ,t 13 ,t 14 ,t 10 ,t 15 ,t 17 ,t 23 ,t 18 ,t 24 ,t 27 }。

Claims (2)

1. a test case reduction method based on weak mutation analysis is characterized by mainly comprising the following steps:
(1) Generating a test case and a variant branch relation matrix based on weak variant transformation: generating n variants M = { M1, M2, M3.. Once.. Mn } for an original program P by using a variant test tool Mujava, constructing corresponding variant branches B = { B1, B2, B3,. Once.. Bn } by combining a log file variant _ log, inserting the variant branches B into corresponding positions of P variant points to form a new program P ', and assuming that M original test case sets T = { T1, T2, T3,. Once.. Tm }, using the new program P', and using the new program P to perform the test on the original program P by using the variant test tool MujavaT execution P' generation test case variation branch relation two-dimensional matrix MT (m+1)×(n+1)
Figure FDA0003839077050000011
Wherein the 0 th row MT in the matrix row0 ={mt 01 ,mt 02 ,...,mt 0n Denotes the mutation branch number (No operation is done in the 0 th row and the 0 th column below), and the 0 th column MT in the matrix col0 ={mt 10 ,mt 20 ,...,mt m0 The test case number is represented; if test case t i ,i∈[1,m]Can cover variant branches b j ,j∈[1,n]Then register mt ij =1, otherwise, register mt ij =0;
(2) Reduction of equivalent variants: for the MT (m + 1) × (n + 1) matrix in the step (1), the MT is used in consideration of the large number of variants, the time complexity of directly solving equivalent variants with operations is large and the difficulty of binary coding caused by the increase of the number of test cases is considered, so the MT is used (m+1)×(n+1) Grouped into rows first
Figure FDA0003839077050000012
Group, wherein l is the custom grouping length; after grouping, the corresponding value Vg = { v } is obtained by using the column in each group as binary code g1 ,v g2 ,v g3 ,...,v gn },g∈[1,G]The g-th group and j-th column have binary codes corresponding to values of
Figure FDA0003839077050000013
So as to the whole MT (m+1)×(n+1) The binary encoding of the matrix corresponds to a value V = { V1, V2, V3, · vn },
Figure FDA0003839077050000014
according to the column reduction of the V pair matrix, the following three cases are divided:
(a) If vj =0, the variant corresponding to the variant branch is an equivalent variant of weak variant analysis, and the jth column of the matrix is recorded and deleted;
(b) If it is
Figure FDA0003839077050000015
All the test cases can kill the variant, so that the variant branch is a test case full-coverage variant branch, the variant corresponding to the variant branch is reduced, and the jth column of the matrix is deleted;
(c) In addition to the two cases described above, if v j =v k Equal (j is more than or equal to 1 and less than or equal to k and less than or equal to n), and v in the group is checked gj And v gk If the values of the first and second values are equal, the variant branches corresponding to the jth and kth columns have the same branch coverage condition, so that the variant corresponding to the variant branch of the kth column is deleted, and the kth column of the matrix is deleted; matrix MT obtained by reduction of equivalent variant (m+1)×r ,r∈[0,n];
(3) Subset test case reduction: the reduction of the test cases of the subset represents the reduction of the test cases corresponding to the variant branch subset, and can be divided into the following parts:
(a) For MT (m+1)×r The matrix counts the variant branch coverage C = { C1, C2, c3..., cm } of each row, the variant branch coverage of the ith row
Figure FDA0003839077050000021
(b) Selecting the maximum value ci, i from C, which belongs to [1,m ∈ ]]Marking the ith row as visited, recording the column index set S = { S } corresponding to the element of the ith row 0 1 ,s 2 ,s 3 ....s h },h∈[1,r]If row i ', i' is e [1,m]If all columns in S are 0, t is the same i ' variant branches which can be covered, t i Must cover, i.e. t i ' is t i Mutating the subset covered by the branches, thus deleting the matrix MT (m+1)×r And C in C i And c i ' delete, traverse all non-visited rows in the matrix, delete matrix MT (m+1)×r Middle t i And deleting the variant branches of the rows corresponding to all the subsets in CCoverage, repeating step 3 (b) until the C set is empty;
(c) Matrix MT obtained by reduction of test case s×r ,s∈[0,m]And (3) obtaining a matrix MT after the equivalent variant reduction in the step (2) s×t ,t∈[0,r];
(4) Reduction of test case: aiming at the matrix MT obtained in the step (3) s×t Due to MT s×t The matrix is a reduced matrix, and at least one branch in each column covers, so the maximum variation branch number Tc of the whole matrix is = t-1, and the ideal covering branch Ic =1111 s×t The matrix is converted into test case binary B, B = { B1, B2, B3., bs-1} in row units, e.g., B1= mt 11 mt 12 mt 13 ....mt 1(t-1) The binary system of the test case variant branch cover and the ideal variant branch cover after bitwise and operation is taken as the actual cover, that is, rx = bx&Ic,x∈[1,s-1]Then, the approximation degree of each test case to the ideal variant branch is counted, and expressed as f' (x) = count (Rx), where count (Rx) is the sum of the number of 1 in the binary system represented by Rx, so that the test case corresponding to the variant branch with the largest approximation degree to the current ideal variant branch is covered as the current optimal solution: f (x) = max (f' (x)), the test data set reduced in the step (3) is used as input, and iterative optimization is carried out by adopting an artificial fish swarm algorithm based on the test case binary code B, and the method specifically comprises the following steps: setting algorithm parameters of initial population number, step length, crowding factor, visual field range and maximum trial frequency, randomly generating an initial population, selecting artificial fishes in the population by foraging, gathering, following and randomly selecting, updating a bulletin board for iteration, searching test cases which can cover the ideal variation branches most, and repeating the step (4) until a test data set covering the maximum branches is generated or the maximum iteration frequency is reached.
2. The test case reduction method according to claim 1, wherein: the method can be applied to regression testing to effectively improve testing efficiency.
CN201810372296.8A 2018-04-24 2018-04-24 Test case reduction method based on weak mutation analysis Active CN110399285B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810372296.8A CN110399285B (en) 2018-04-24 2018-04-24 Test case reduction method based on weak mutation analysis

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810372296.8A CN110399285B (en) 2018-04-24 2018-04-24 Test case reduction method based on weak mutation analysis

Publications (2)

Publication Number Publication Date
CN110399285A CN110399285A (en) 2019-11-01
CN110399285B true CN110399285B (en) 2022-11-15

Family

ID=68320197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810372296.8A Active CN110399285B (en) 2018-04-24 2018-04-24 Test case reduction method based on weak mutation analysis

Country Status (1)

Country Link
CN (1) CN110399285B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111597103B (en) * 2020-03-23 2023-11-28 浙江工业大学 Method for reducing state space of embedded software SysML model
CN112699050A (en) * 2020-08-03 2021-04-23 徐州工程学院 Multi-population evolution generation method for software test case based on variant grouping
CN114091622A (en) * 2021-12-07 2022-02-25 西安邮电大学 Variant reduction method based on self-organizing mapping neural network

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102253889A (en) * 2011-08-07 2011-11-23 南京大学 Method for dividing priorities of test cases in regression test based on distribution
CN104268077A (en) * 2014-09-23 2015-01-07 湖州师范学院 Chaos genetic algorithm based test case intensive simple algorithm
CN106991051A (en) * 2017-04-05 2017-07-28 西安邮电大学 A kind of test case reduction method based on mutation testing and correlation rule

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9910763B1 (en) * 2016-08-18 2018-03-06 International Business Machines Corporation Test case reduction in application binary interface (ABI) compatibility testing

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102253889A (en) * 2011-08-07 2011-11-23 南京大学 Method for dividing priorities of test cases in regression test based on distribution
CN104268077A (en) * 2014-09-23 2015-01-07 湖州师范学院 Chaos genetic algorithm based test case intensive simple algorithm
CN106991051A (en) * 2017-04-05 2017-07-28 西安邮电大学 A kind of test case reduction method based on mutation testing and correlation rule

Non-Patent Citations (8)

* Cited by examiner, † Cited by third party
Title
Test Suite Minimization with Mutation Testing-Based Many-Objective Evolutionary Optimization;Zheng Wei;《2017 International Conference on Software Analysis, Testing and Evolution (SATE)》;20171123;全文 *
基于人工免疫算法的高效回归测试用例集约简机制;刘文静等;《东南大学学报(自然科学版)》;20171120;全文 *
基于动态集合进化算法的弱变异测试用例集生成;郭后钱等;《计算机应用》;20170910;全文 *
基于变异分析的测试用例约简方法;王曙燕等;《计算机应用》;20171210(第12期);全文 *
基于向量相似度的测试用例集约简方法;刘锋等;《微电子学与计算机》;20170305(第03期);全文 *
基于改进鱼群算法的路径测试数据生成;王培崇等;《计算机应用》;20130401(第04期);全文 *
基于矩阵行列变换的测试用例约简算法;周冲波等;《计算机应用研究》;20130315(第03期);全文 *
基于统计占优分析的变异测试;张功杰等;《软件学报》;20151015(第10期);全文 *

Also Published As

Publication number Publication date
CN110399285A (en) 2019-11-01

Similar Documents

Publication Publication Date Title
Fuentes et al. High-performance deep neural network-based tomato plant diseases and pests diagnosis system with refinement filter bank
CN110399285B (en) Test case reduction method based on weak mutation analysis
Manivannan et al. Dengue fever prediction using K-means clustering algorithm
CN111710364B (en) Method, device, terminal and storage medium for acquiring flora marker
CN106682454A (en) Method and device for data classification of metagenome
Chouhan et al. A deep learning approach for the classification of diseased plant leaf images
CN110110753A (en) Effective hybrid characteristic selecting method of pollination algorithm and ReliefF is spent based on elite
CN116564409A (en) Machine learning-based identification method for sequencing data of transcriptome of metastatic breast cancer
CN114242178A (en) Method for quantitatively predicting biological activity of ER alpha antagonist based on gradient lifting decision tree
Brown et al. LSHPlace: fast phylogenetic placement using locality-sensitive hashing
CN116129189A (en) Plant disease identification method, plant disease identification equipment, storage medium and plant disease identification device
CN116188855A (en) Multi-scale plant disease identification method, device, storage medium and apparatus
Aburas et al. ICC World Cup Prediction Based Data Analytics and Business Intelligent (BI) Techniques
CN115511798A (en) Pneumonia classification method and device based on artificial intelligence technology
CN114566234A (en) Quantitative optimization method and system for anticancer candidate drug compound molecules
Roy et al. Disease Detection in Paddy Crop using Machine Learning Techniques
CN112906634A (en) Video segment sequence prediction model establishment and sequence prediction method and system based on VSS
CN115409079A (en) Matrix processing device, method and processing equipment
CN112447292A (en) Human body index-stroke relation analysis system based on machine learning interpretability
CN111383716A (en) Method and device for screening gene pairs, computer equipment and storage medium
Zarayeneh et al. Antimicrobial peptide prediction using ensemble learning algorithm
Cudic et al. Prediction of sorghum bicolor genotype from in-situ images using autoencoder-identified SNPs
CN110766087A (en) Method for improving data clustering quality of k-means based on dispersion maximization method
Roy et al. New crossover operators for multiple subset selection tasks
Muhali et al. A Comparison of Keras Application Models with Pre-Trained Weights in Predicting the Disease of Lanzones Leaf

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant