Test case priority ranking method based on multi-sequence fusion
Through the multi-sequence fusion test case priority sorting method, combining test case correlation and changing code characteristics, multiple evaluation functions are built and the use case sequence is adjusted, which solves the problem of high time cost of test case sorting in the existing technology, and achieves high efficiency , accurate test case sorting.
Patent Information
- Application Number
- CN202411054436.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-08-02
AI Technical Summary
The existing test case sorting method has high time cost and poor results under the conditions of ensuring the effect, making it difficult to effectively reduce the time consumption during software testing.
Using the test case priority sorting method based on multi-sequence fusion, by obtaining test case sets and regression test history results, combining the correlation between test cases and changing the code structure characteristics, building a variety of evaluation functions, adjusting the use case sequence, and executing the code using code Logic generates a final priority sequence, reducing time consumption.
The performance and accuracy of the test case set is significantly improved, time consumption is reduced through multi-sequence parallel mode, and more efficient test case sorting is achieved.
Smart Images

Figure CN119127665A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a test case priority sorting method based on multi-sequence fusion. Background Art
[0002] In the entire software life cycle, regression testing is an essential link and takes up a lot of time. At present, with the increasing frequency of software changes, the testing requirements for effects and time are constantly increasing, which brings great challenges to software testing.
[0003] Test case priority is an indicator for evaluating the importance of test cases. This indicator can be used to adjust the execution order of test cases so as to find test failures as early as possible. Test case ranking optimization technology (TCP) is one of the effective methods for regression testing and is highly favored. At present, there are many kinds of information used to measure the priority of test cases, such as code coverage, fault detection level, degree of change, risk level, and customer needs. Test case ranking technologies based on different information have their own characteristics and have achieved good results. However, the test case ranking method that only considers certain information is not accurate enough. For example, the method that only uses information such as branch coverage or statement coverage in code coverage can reflect the test performance of the test case, but fails to determine the correlation between these test cases and the changed code, resulting in poor regression testing results. In addition, the test case ranking method that uses multiple information has a high time cost. For example, the machine learning algorithm that uses information such as software scale, complexity, and code structure characteristics has a good ranking effect, but has high requirements on the quantity and quality of data and a large time cost.
[0004] Therefore, how to effectively reduce the time cost of the sorting method and the testing process while ensuring the effectiveness of the use case test is an urgent problem to be solved in the software testing process. Summary of the invention
[0005] Purpose of the invention: In view of the above problems, the purpose of the present invention is to provide a test case priority sorting method based on multi-sequence fusion.
[0006] Technical solution: A test case priority sorting method based on multi-sequence fusion of the present invention comprises the following steps:
[0007] Step 1: Obtain a test case set and historical regression test results, pre-process the test case set according to the correlation between the test cases, and obtain a first test case set;
[0008] Step 2: Reprocess the first test case set according to the historical results of the regression test to obtain a second test case set, and construct a first test case evaluation function to obtain a first test case priority sequence S1;
[0009] Step 3: Reprocess the first test case set using the structural features of the changed code to obtain a third test case set, and construct a second test case evaluation function to obtain a second test case priority sequence S2;
[0010] Step 4: Obtain the shortest common subsequence of the first test case priority sequence S1 and the second test case priority sequence S2, use the code execution logic to adjust the order of the test cases of the shortest common subsequence, replace the adjusted shortest common subsequence with the original sequence, and obtain the test case priority sequence of the changed software.
[0011] Further, the test case set is preprocessed according to the correlation between the test cases, and the first test case set is obtained, including:
[0012] According to the coverage of test cases in the test process, a relationship matrix M between test cases and coverage targets is established, where the coverage target is denoted as O = {o i |i=1,2,…,m},o i represents the i-th target, m is the number of targets, and will cover every target o in O i The test case set is denoted as T = {t j |j=1,2,…,n},t j represents the jth test case, n is the number of test cases, then M is expressed as:
[0013] M=[t 1 (O),…,t j (O),…,t n (O)]
[0014] Among them, t j (O) is the vector of coverage targets for the jth test case, t j (O) = {t j (o i )|i=1,2,…,m},t j (o i ) indicates the target o i Whether the test case t j Cover, if o i t j Coverage, t j (o i )=1; otherwise, t j (o i )=0;
[0015] The Hamming distance is used to calculate the similarity between the coverage targets of each test case, and the similarity is compared with the similarity threshold θ. When the similarity is less than the similarity threshold θ, the corresponding test cases in M are retained to the new set M′. Otherwise, the target coverage of the two test cases is calculated one by one, and the test cases with larger coverage in M are retained to the new set M′, and the new set M′ is used as the first test case set.
[0016] Further, step 2 includes:
[0017] Selecting the main features of the test cases and their characterization vectors according to the historical results of the regression test, calculating the maximum information coefficient between the features, and screening the first test case set according to the maximum information coefficient to obtain the second test case set;
[0018] Normalize the characteristic values of the test cases in the second test case set, and construct the first test case evaluation function f according to the normalization result 1 (t), the expression is:
[0019]
[0020] Where, T i (t) is the ith eigenvalue in test case t, α i represents the weight of the i-th feature for test case t, m 1 is the number of features in the first test case set;
[0021] The bucket sorting algorithm is used in combination with the evaluation scores of the test cases to generate a first test case priority sequence S1.
[0022] Further, using the bucket sorting algorithm and combining the evaluation scores of the test cases, a first test case priority sequence S1 is generated, including:
[0023] Evaluate the function f according to the first test case 1 (t) Calculate the evaluation score of each test case and evenly divide the evaluation score into several sub-buckets;
[0024] Use the binary sorting principle to sort the test cases in the sub-bucket;
[0025] The sub-buckets are merged in sequence to form a first test case priority sequence S1.
[0026] Further, step 3 includes:
[0027] Selecting features related to the changed code in the first test case set, calculating the maximum information coefficient between the features, and screening the first test case set according to the maximum information coefficient to obtain a third test case set;
[0028] Normalize the features of the test cases in the third test case set, and construct the second test case evaluation function f according to the normalization results. 2 (t), the expression is:
[0029]
[0030] In the formula, H i is the i-th eigenvalue of the change code block, β i represents the weight of the i-th feature on the changed code block, m 2 is the size of the feature subset;
[0031] Find unchanged code blocks similar to the changed code blocks in the software before the change, obtain test cases corresponding to the similar unchanged code blocks, and use them as test cases corresponding to the changed code;
[0032] Use the second test case to evaluate the function f 2 (t) Calculate the evaluation values of the test cases corresponding to the changed code, and sort the test cases corresponding to the changed code blocks according to the evaluation values to form a second test case priority sequence S2.
[0033] Further, screening the first test case set according to the maximum information coefficient includes:
[0034] Set the maximum information coefficient threshold MIC 0 , delete the first test case set with a value less than MIC 0 The features corresponding to the maximum information coefficient are retained to be no less than MIC 0 The feature corresponding to the maximum information coefficient is used to record the retained first test case set as the second test case set or the third test case set.
[0035] Furthermore, searching for unchanged code blocks similar to the changed code blocks in the software before the change, and obtaining test cases corresponding to the similar unchanged code blocks includes:
[0036] The unchanged code block is denoted as W = {w 1 , w 2 ,…,w i ,…,w h}, where w i represents the i-th execution path, and h is the total number of execution paths contained in the unchanged code block;
[0037] The changed code block is recorded as W′={w 1 ′,w 2 ′,…,w i ′,…,w g ′}, where w i′ is the i-th execution path, g is the total number of execution paths included in the changed code block;
[0038] Calculate the similarity sim(W,W′) between the changed code block and the unchanged code block. The expression is:
[0039]
[0040] Where W∩W′ represents the number of identical elements in W and W′, and min(|W|,|W′|) represents the modulus of the set with the least number of elements in the two sets.
[0041] The similarity degree is greater than the similarity threshold sim 0 The unchanged code block of is treated as an unchanged code block similar to the changed code block.
[0042] Further, in step 4, the lengths of the first test case priority sequence S1 and the second test case priority sequence S2 are compared, and the longer sequence is used as the original sequence.
[0043] Furthermore, the formula for calculating the similarity between the coverage targets of each test case in step 1 is:
[0044]
[0045] In the formula, t j (O)∩t j′ (O) is the vector t j (O) and t j′ The number of different components at corresponding positions in (O), t j and t j′ denote the jth and j′th test cases respectively;
[0046] The calculation expression of target coverage is:
[0047]
[0048] Furthermore, the calculation formula of the maximum information coefficient is:
[0049]
[0050] In the formula, X and Y represent two different features of the test case, and parameter B = b 0.6 , b represents the length of the feature vector; I[X; Y] is the mutual information of features X and Y, and the calculation formula is:
[0051]
[0052] Where p(X,Y) is the joint density function of feature X and feature Y, and p(X) and p(Y) are the probability density functions of feature X and feature Y respectively.
[0053] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages:
[0054] This invention combines multiple test case sequences to improve the performance of the test case set from different perspectives:
[0055] First, the test case relevance is used and combined with feature selection strategy to reduce the test case set;
[0056] Secondly, historical test information is used and a test case evaluation function is constructed to implement test case priority sorting;
[0057] Then, the test case priority sequence is generated by using the structural features of the changed code and combining the similarity with the unchanged code;
[0058] Finally, the program execution logic is used to adjust multiple test sequences and generate the final test case priority order. The comparative verification through engineering examples shows that the test case sequence obtained by the present invention has the advantages of strong performance and high precision, and the parallel mode of multiple sequence generation reduces time consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a flowchart of the test case prioritization method based on multi-sequence fusion;
[0060] Figure 2 The process of obtaining the first test case priority sequence in the embodiment, (a) is a similarity heat map between test cases, (b) is a schematic diagram of screening test cases, and (c) is a schematic diagram of the first test case priority sequence;
[0061] Figure 3 It is a flowchart of the bucket sorting algorithm in the embodiment;
[0062] Figure 4 It is a schematic diagram of obtaining the test case priority sequence of the changed software in the embodiment. DETAILED DESCRIPTION
[0063] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0064] The test case priority sorting method based on multi-sequence fusion described in this embodiment has a flowchart as shown in FIG. Figure 1 As shown, the method comprises the following steps:
[0065] Step 1: Obtain a test case set and historical regression test results, pre-process the test case set according to the correlation between the test cases, and obtain a first test case set;
[0066] Step 2: Reprocess the first test case set according to the historical results of the regression test to obtain a second test case set, and construct a first test case evaluation function to obtain a first test case priority sequence S1;
[0067] Step 3: Reprocess the first test case set using the structural features of the changed code to obtain a third test case set, and construct a second test case evaluation function to obtain a second test case priority sequence S2;
[0068] Step 4: Obtain the shortest common subsequence of the first test case priority sequence S1 and the second test case priority sequence S2, use the code execution logic to adjust the case order of the shortest common subsequence, replace the adjusted shortest common subsequence with the original sequence, complete multi-sequence fusion, and finally obtain the test case priority sequence of the changed software.
[0069] In step 1, the test case set is preprocessed according to the correlation between the test cases, and the first test case set is obtained, including:
[0070] According to the coverage of test cases in the test process, a relationship matrix M between test cases and coverage targets is established, where the coverage target is denoted as O = {o i |i=1,2,…,m},o i represents the i-th target, m is the number of targets, and will cover every target o in O i The test case set is denoted as T = {t j |j=1,2,…,n},t j represents the jth test case, n is the number of test cases, then M is expressed as:
[0071] M=[t 1 (O),…,t j (O),…,t n (O)]
[0072] Among them, t j (O) is the vector of coverage targets for the jth test case, t j (O) = {t j (o i )|i=1,2,…,m},t j (o i ) indicates the target o i Whether the test case t j Cover, if o i t j Coverage, t j (o i )=1; otherwise, t j (o i)=0;
[0073] The similarity between the coverage targets of each test case is calculated using the Hamming distance. The correlation between test cases is expressed by similarity to achieve the purpose of reducing the test case set. The similarity is compared with the similarity threshold θ. When the similarity is less than the similarity threshold θ, the corresponding test cases in M are retained in the new set M′. Otherwise, the target coverage of the two test cases is calculated one by one, and the test cases with larger coverage in M are retained in the new set M′. The new set M′ is used as the first test case set.
[0074] Furthermore, the formula for calculating the similarity between the coverage targets of each test case in step 1 is:
[0075]
[0076] In the formula, t j (O)∩t j′ (O) is the vector t j (O) and t j′ (O) is the number of different components at the corresponding position, m is the total number of covered targets, t j and t j′ denote the jth and j′th test cases respectively;
[0077] The calculation expression of target coverage is:
[0078]
[0079] In the formula, t j (o i ) indicates whether the i-th target is tested by test case t j cover.
[0080] Take the test example in Table 1 for example. This test example contains 7 test cases. 1 …t 7 and its corresponding coverage target information, q 1 …q 6 Indicates the coverage target, such as target q 1 t 1 Therefore, the corresponding coverage target information is 1, and the target q 2 Not t 1 Therefore, the corresponding coverage target information is 0. From Table 1, we can see that the initial test case set C = {t 1 , t 2 , t 3 , t 4 , t 5 , t 6 , t 7}, the similarity between two test cases is calculated based on the information of the corresponding coverage targets listed in Table 1. The calculation results are as follows Figure 2 As shown in Figure (a), in this example, the similarity threshold θ is set to 0.8. By comparing the similarity with the threshold 0.8, we can see that the test case t 3 and t 6 The similarity between them is 0.82, which is higher than the threshold of 0.8. Figure 2 As shown in Figure (b), the target coverage of the two test cases is calculated using the formula, which are OC(t 3 )=2 / 6=0.33,OC(t 6 )=3 / 6=0.50, so the test cases with larger target coverage are retained. 6 To the new set C′, such as Figure 2 As shown in Figure (c), the reduced first test case set C′={t 1 , t 2 , t 4 , t 5 , t 6 , t 7}.
[0081] Table 1 Test case-target coverage matrix
[0082] <![CDATA[q 1 ]]> <![CDATA[q 2 ]]> <![CDATA[q 3 ]]> <![CDATA[q 4 ]]> <![CDATA[q 5 ]]> <![CDATA[q 6 ]]> … <![CDATA[t 1 ]]> 1 0 0 1 0 0 … <![CDATA[t 2 ]]> 1 1 1 0 0 1 … <![CDATA[t 3 ]]> 0 1 0 0 1 0 … <![CDATA[t 4 ]]> 0 1 1 1 0 0 … <![CDATA[t 5 ]]> 0 0 1 0 1 0 … <![CDATA[t 6 ]]> 0 1 0 0 1 1 … <![CDATA[t 7 ]]> 0 0 0 1 0 0 …
[0083] Specifically, step 2 includes:
[0084] Selecting the main features of the test cases and their characterization vectors according to the historical results of the regression test, calculating the maximum information coefficient between the features, and screening the first test case set according to the maximum information coefficient to obtain the second test case set;
[0085] The characteristic values of the test cases in the second test case set are normalized to avoid the influence of differentiated dimensions on subsequent calculations, and the first test case evaluation function f is constructed based on the normalized results. 1 (t), the expression is:
[0086]
[0087] Where, T i (t) is the ith eigenvalue in test case t, α i represents the weight of the i-th feature for test case t, m 1 is the number of features in the first test case set;
[0088] The bucket sorting algorithm is used in combination with the evaluation scores of the test cases to generate a first test case priority sequence S1.
[0089] In step 2, screening the first test case set according to the maximum information coefficient includes:
[0090] Set the maximum information coefficient threshold MIC 0 , delete the first test case set with a value less than MIC 0 The features corresponding to the maximum information coefficient are retained to be no less than MIC 0 The feature corresponding to the maximum information coefficient is used, and the retained first test case set is recorded as the second test case set.
[0091] In step 2, the first test case set is screened and optimized based on unstructured data such as test information, and finally the first test case priority sequence S1 is obtained. According to the historical results of regression testing, the main features of the test cases are selected, including the number of case fault detections, fault categories, risk levels, test scales, and execution time information, as the features for evaluating the test cases, and the feature values of each feature are obtained. For the specific value of a feature that cannot be obtained in the test results, for the convenience of subsequent calculations, the feature value is replaced by 0, and finally the characterization vector of each feature is obtained, where the characterization vector is composed of multiple feature values.
[0092] Calculate the maximum information coefficient and then get the correlation between features. Let the two features of the test case be X and Y. The calculation formula for the maximum information coefficient of features X and Y is:
[0093]
[0094] In the formula, X and Y represent two different features of the test case, and parameter B = b 0.6 , b represents the length of the feature vector; I[X; Y] is the mutual information of features X and Y, and the calculation formula is:
[0095]
[0096] Where p(X,Y) is the joint density function of feature X and feature Y, and p(X) and p(Y) are the probability density functions of feature X and feature Y respectively.
[0097] Further, using the bucket sorting algorithm and combining the evaluation scores of the test cases, the first test case priority sequence S1 is generated, including:
[0098] Evaluate the function f according to the first test case 1 (t) Calculate the evaluation score of each test case and evenly divide the evaluation score into several sub-buckets;
[0099] Use the binary sorting principle to sort the test cases in the sub-bucket;
[0100] The sub-buckets are merged in sequence to form a first test case priority sequence S1.
[0101] like Figure 3 As shown, in one example, after data preprocessing, the first test case set C′={t 1 , t 2 , t 4 , t 5 , t 6 , t 7}, after feature selection, the evaluation index value of each test case is obtained, C = {f 1 (t 1 ), f 1 (t 2 ), f 1 (t 4 ), f 1 (t 5 ), f 1 (t 6 ), f 1 (t 7 )}. Use the bucket sort algorithm to sort them, as follows:
[0102] The evaluation scores are assigned to different sub-buckets according to their data distribution, and sub-buckets containing several test cases and with IDs of 0, 1, and 2 are obtained in turn. The evaluation scores are used in each sub-bucket, and the scores are sorted in combination with the binary method to sort the data in the sub-buckets. Finally, the sub-buckets are merged in turn to form the first test case priority sequence S1={t 1 , t 2 , t 5 , t 4 , t 6 , t 7}.
[0103] Further, step 3 includes:
[0104] Selecting features related to the changed code in the first test case set, calculating the maximum information coefficient between the features, and screening the first test case set according to the maximum information coefficient to obtain a third test case set;
[0105] Considering the influence of the difference dimension, each feature of the test case in the third test case set is normalized, and the second test case evaluation function f is constructed according to the normalization result. 2 (t), the expression is:
[0106]
[0107] In the formula, H i is the i-th eigenvalue of the changed code block, β i represents the weight of the i-th feature on the changed code block, m2 is the size of the feature subset;
[0108] Find unchanged code blocks similar to the changed code blocks in the software before the change, obtain test cases corresponding to the similar unchanged code blocks, and use them as test cases corresponding to the changed code;
[0109] Use the second test case to evaluate the function f 2 (t) Calculate the evaluation values of the test cases corresponding to the changed code, and sort the test cases corresponding to the changed code blocks according to the evaluation values to form a second test case priority sequence S2.
[0110] In step 3, the first test case set is processed according to structured data such as the change code, and finally the second test case priority sequence S2 is obtained. The selected features related to the change code include the number of change lines, change depth, cyclomatic complexity, coupling degree, number of variables, implementation functions and other easily accessible features. The test cases corresponding to similar code units are obtained, and the sequence of these test cases is obtained according to the order of the change code blocks. The code block contains one or more execution paths composed of statements, which can be represented as a set of execution paths. The more identical elements there are in the two sets, the more similar they are.
[0111] In step 3, screening the first test case set according to the maximum information coefficient includes:
[0112] Set the maximum information coefficient threshold MIC 0 , delete the first test case set with a value less than MIC 0 The features corresponding to the maximum information coefficient are retained to be no less than MIC 0 The feature corresponding to the maximum information coefficient of is selected, and the first test case set retained is recorded as the third test case set. It should be noted that the maximum information coefficient threshold here and the maximum information coefficient threshold in step 2 can take different values.
[0113] Find unchanged code blocks similar to the changed code blocks in the software before the change, and obtain the test cases corresponding to the similar unchanged code blocks, including:
[0114] The unchanged code block is denoted as W = {w 1 , w 2 ,…,w i ,…,w h}, where w i represents the i-th execution path, and h is the total number of execution paths contained in the unchanged code block;
[0115] The changed code block is recorded as W′={w 1 ′,w 2 ′,…,w i ′,…,wg ′}, where w i ′ is the i-th execution path, g is the total number of execution paths included in the changed code block;
[0116] Calculate the similarity sim(W,W′) between the changed code block and the unchanged code block. The expression is:
[0117]
[0118] Where W∩W′ represents the number of identical elements in W and W′, and min(|W|,|W′|) represents the modulus of the set with the least number of elements in the two sets.
[0119] The similarity degree is greater than the similarity threshold sim 0 The unchanged code block of is treated as an unchanged code block similar to the changed code block.
[0120] In step 4, compare the first test case priority sequence S 1 and the second test case priority sequence S 2 length, and take the longer sequence as the original sequence.
[0121] In one example, if Figure 4 As shown, the first test case priority sequence is S 1 ={t 1 , t 2 , t 5 , t 4 , t 6 , t 7}, the second test case priority sequence is S 2 ={t 1 , t 4 , t 2}, the longer sequence S 1 As the original sequence, in S 1 Find S in 2 The position of each element in the array is calculated and placed in the new array S', that is, S' = [0,3,1]. By comparing the values in S', we get the minimum value 0 and the maximum value 3, S 1 The sequence between the minimum and maximum values in must contain S 2 , therefore, take out the sequence S 1 [0:3], and cover S′, and get the shortest common subsequence S′, that is, S′=[t 1 , t 2 , t 5 , t 4 ].
[0122] Identify sequence S′ and sequence S 2The difference of the elements in S′ is obtained by obtaining the elements with different order and their positions in S′, such as (t 2 , t 4 ) and (t 4 , t 2 ), such as during the test 4 The corresponding code precedes t 2 The corresponding code block is executed, and the order of the two use cases in S′ is adjusted to [t 4 , t 2 ], Figure 4 After the two sequences are operated in this part, the adjusted shortest common subsequence is replaced with the original sequence, and finally the use case priority sequence S = [t 1 , t 4 , t 5 , t 2 , t 6 , t 7 ].
[0123] In order to verify the effectiveness of the sorting method MS-TCP proposed in this embodiment, the existing BTCPtopic and WTCPtotal algorithms are used as comparison objects, where BTCPtopic is a black-box test case prioritization technology based on test information, and WTCPtotal is a white-box test case prioritization technology based on coverage and source code analysis. They are verified in 7 open source projects respectively. APFD represents the average fault detection percentage of test cases, which is the most widely used indicator to measure the effectiveness of test case prioritization technology. It is used as an evaluation indicator of method performance. The larger its value, the better the effect of the test case sequence. The calculation expression is:
[0124]
[0125] Where T is the test case set, m is the number of faults detected by the test cases in T, n is the number of all units in T, and TF is i represents the first unit in T that detects fault i.
[0126] The evaluation index values of various methods are shown in Table 2. It can be seen from the table that the APFD values in the present invention are all the largest, indicating that the test effect is the best.
[0127] Table 2 APFD of various methods
[0128]
Claims
1. A test case prioritization method based on multi-sequence fusion, characterized in that: The steps include: Step 1: Obtain a test case set and historical regression test results, pre-process the test case set according to the correlation between the test cases, and obtain a first test case set; Step 2: Reprocess the first test case set according to the historical results of the regression test to obtain a second test case set, and construct a first test case evaluation function to obtain a first test case priority sequence S1; Step 3: Reprocess the first test case set using the structural features of the changed code to obtain a third test case set, and construct a second test case evaluation function to obtain a second test case priority sequence S2; Step 4: Obtain the shortest common subsequence of the first test case priority sequence S1 and the second test case priority sequence S2, use the code execution logic to adjust the order of the test cases of the shortest common subsequence, replace the adjusted shortest common subsequence with the original sequence, and obtain the test case priority sequence of the changed software.
2. The test case priority sorting method based on multi-sequence fusion according to claim 1 is characterized in that: The test case set is preprocessed according to the correlation between the test cases, and the first test case set is obtained, including: According to the coverage of test cases in the test process, a relationship matrix M between test cases and coverage targets is established, where the coverage target is denoted as O = {o i |i=1,2,…,m},o i represents the i-th target, m is the number of targets, and will cover every target o in O i The test case set is denoted as T = {t j |j=1,2,…,n},t j represents the jth test case, n is the number of test cases, then M is expressed as: M=[t1(O),…,t j (O),…,t n (O)] Among them, t j (O) is the vector of coverage targets for the jth test case, t j (O) = {t j (o i )|i=1,2,…,m},t j (o i ) indicates the target o i Whether the test case t j Cover, if o i t j Coverage, t j (o i )=1; otherwise, t j (o i )=0; The Hamming distance is used to calculate the similarity between the coverage targets of each test case, and the similarity is compared with the similarity threshold θ. When the similarity is less than the similarity threshold θ, the corresponding test cases in M are retained to the new set M′. Otherwise, the target coverage of the two test cases is calculated one by one, and the test cases with larger coverage in M are retained to the new set M′, and the new set M′ is used as the first test case set.
3. The test case prioritization method based on multi-sequence fusion according to claim 1 is characterized in that: Step 2 includes: Selecting the main features of the test cases and their characterization vectors according to the historical results of the regression test, calculating the maximum information coefficient between the features, and screening the first test case set according to the maximum information coefficient to obtain the second test case set; The characteristic values of the test cases in the second test case set are normalized, and the first test case evaluation function f1(t) is constructed according to the normalization result, and the expression is: Where, T i (t) is the ith eigenvalue in test case t, α i represents the weight of the i-th feature for test case t, m1 is the number of features in the first test case set; The bucket sorting algorithm is used in combination with the evaluation scores of the test cases to generate a first test case priority sequence S1.
4. The test case priority sorting method based on multi-sequence fusion according to claim 3 is characterized in that: Using the bucket sorting algorithm and combining the evaluation scores of the test cases, the first test case priority sequence S1 is generated, including: Calculate the evaluation score of each test case according to the first test case evaluation function f1(t), and evenly divide the evaluation score into several sub-buckets; Use the binary sorting principle to sort the test cases in the sub-bucket; The sub-buckets are merged in sequence to form a first test case priority sequence S1.
5. The test case priority sorting method based on multi-sequence fusion according to claim 1 is characterized in that: Step 3 includes: Selecting features related to the changed code in the first test case set, calculating the maximum information coefficient between the features, and screening the first test case set according to the maximum information coefficient to obtain a third test case set; The features of the test cases in the third test case set are normalized, and the second test case evaluation function f2(t) is constructed according to the normalization result, and the expression is: In the formula, H i is the i-th eigenvalue of the change code block, β i represents the weight of the i-th feature on the changed code block, m2 is the size of the feature subset; Find unchanged code blocks similar to the changed code blocks in the software before the change, obtain test cases corresponding to the similar unchanged code blocks, and use them as test cases corresponding to the changed code; The second test case evaluation function f2(t) is used to calculate the evaluation value of the test case corresponding to the changed code, and the test cases corresponding to the changed code block are sorted according to the evaluation value to form a second test case priority sequence S2.
6. The test case priority sorting method based on multi-sequence fusion according to claim 3 or 5, characterized in that: Screening the first test case set according to the maximum information coefficient includes: Set the maximum information coefficient threshold MIC0, delete the features corresponding to the maximum information coefficient less than MIC0 in the first test case set, retain the features corresponding to the maximum information coefficient not less than MIC0, and record the retained first test case set as the second test case set or the third test case set.
7. The test case priority sorting method based on multi-sequence fusion according to claim 6 is characterized in that: Find unchanged code blocks similar to the changed code blocks in the software before the change, and obtain the test cases corresponding to the similar unchanged code blocks, including: The unchanged code block is denoted as W = {w1, w2, ..., w i ,…,w h }, where w i represents the i-th execution path, and h is the total number of execution paths contained in the unchanged code block; The changed code block is recorded as W′={w1′, w2′, …, w i ′,…,w g ′}, where w i ′ is the i-th execution path, g is the total number of execution paths included in the changed code block; Calculate the similarity sim(W,W′) between the changed code block and the unchanged code block. The expression is: Where W∩W′ represents the number of identical elements in W and W′, and min(|W|,|W′|) represents the modulus of the set with the least number of elements in the two sets. Unchanged code blocks whose similarity is greater than the similarity threshold sim0 are regarded as unchanged code blocks similar to the changed code blocks.
8. The test case priority sorting method based on multi-sequence fusion according to claim 1 is characterized in that: In step 4, the lengths of the first test case priority sequence S1 and the second test case priority sequence S2 are compared, and the longer sequence is used as the original sequence.
9. The test case priority sorting method based on multi-sequence fusion according to claim 2 is characterized in that: The formula for calculating the similarity between the coverage targets of each test case in step 1 is: Where, t j (O)∩t j′ (O) is the vector t j (O) and t j′ The number of different components at corresponding positions in (O), t j and t j′ denote the jth and j′th test cases respectively; The calculation expression of target coverage is:
10. The test case priority sorting method based on multi-sequence fusion according to claim 3 is characterized in that: The calculation formula of the maximum information coefficient is: In the formula, X and Y represent two different features of the test case, and parameter B = b 0.6 , b represents the length of the feature vector; I[X; Y] is the mutual information of features X and Y, and the calculation formula is: Where p(X,Y) is the joint density function of feature X and feature Y, and p(X) and p(Y) are the probability density functions of feature X and feature Y respectively.
Citation Information
Patent Citations
Test process tracking method and system for Java function call path
CN104536895A
Test case reusing method based on code similarity
CN115237758A
Test case sorting method based on ship code coverage representation learning
CN116302983A
Adaptive Framework Automatically Prioritizing Software Test Cases
US20160162392A1
Deep q-network reinforcement learning for testing case selection and prioritization
US20210064515A1
