Test case prioritization method based on multi-sequence fusion
By adopting a test case priority sorting method based on multi-sequence fusion in software testing, combining test case correlation and changing code structure characteristics, the problems of inaccurate test case sorting and high time cost in the existing technology are solved, and efficient and accurate test case sorting and reducing time consumption are achieved.
Patent Information
- Application Number
- CN202411054436.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-08-02
AI Technical Summary
The prior art is difficult to effectively reduce the time cost of test case sorting methods and test processes in software testing, and the test case sorting methods that only consider certain information are not accurate enough, and the correlation between test cases and change code cannot be determined.
Using a test case priority sorting method based on multi-sequence fusion, a variety of test case evaluation functions are constructed by obtaining test case sets and regression test history results, combining the correlation between test cases and the structural characteristics of the change code, multiple test case evaluation functions are built, multiple test case priority sequences are generated, and logical adjustments are performed through the shortest common subsequence and code to finally generate the final test case priority order.
It improves the performance of the test case set, realizes the accuracy and efficiency of test case prioritization, reduces time consumption, and improves the test effect through the parallel mode generated by multiple sequences.
Smart Images

Figure CN119127665B_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=[t1(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] 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:
[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, m1 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] 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;
[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] Each feature of the test case in the third test case set is normalized, and the second test case evaluation function f2(t) is constructed according to the normalization result, and 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, m2 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] 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.
[0033] Further, screening the first test case set according to the maximum information coefficient includes:
[0034] 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.
[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 = {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;
[0037] 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;
[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] Unchanged code blocks whose similarity is greater than the similarity threshold sim0 are regarded as unchanged code blocks similar to the changed code blocks.
[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] 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;
[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=[t1(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] Where, 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] Where, 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 illustration. This test example contains 7 test cases t1…t7 and their corresponding coverage target information. q1…q6 represent coverage targets. For example, if target q1 is covered by t1, the corresponding coverage target information is 1. If target q2 is not covered by t1, the corresponding coverage target information is 0. From Table 1, we can see that the initial test case set C = {t1, t2, t3, t4, t5, t6, t7}. Based on the information of the corresponding coverage targets listed in Table 1, we can calculate the similarity between the two test cases. 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, it can be seen that the similarity between test cases t3 and t6 is 0.82, which is higher than the threshold 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(t3)=2 / 6=0.33 and OC(t6)=3 / 6=0.50 respectively. Therefore, the test case t6 with a larger target coverage is retained in the new set C′, as shown in Figure 2As shown in the middle figure (c), the reduced first test case set C′={t1, t2, t4, t5, t6, t7} is formed.
[0081] Table 1 Test case-target coverage matrix
[0082] <![CDATA[q1]]> <![CDATA[q2]]> <![CDATA[q3]]> <![CDATA[q4]]> <![CDATA[q5]]> <![CDATA[q6]]> … <![CDATA[t1]]> 1 0 0 1 0 0 … <![CDATA[t2]]> 1 1 1 0 0 1 … <![CDATA[t3]]> 0 1 0 0 1 0 … <![CDATA[t4]]> 0 1 1 1 0 0 … <![CDATA[t5]]> 0 0 1 0 1 0 … <![CDATA[t6]]> 0 1 0 0 1 1 … <![CDATA[t7]]> 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. The first test case evaluation function f1(t) is constructed based on the normalized results. 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, m1 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] The maximum information coefficient threshold MIC0 is set, features corresponding to the maximum information coefficient less than MIC0 in the first test case set are deleted, features corresponding to the maximum information coefficient not less than MIC0 are retained, 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] 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;
[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′={t1, t2, t4, t5, t6, t7} is obtained, and after feature selection, the evaluation index value of each test case is obtained, C={f1(t1), f1(t2), f1(t4), f1(t5), f1(t6), f1(t7)}. The bucket sorting algorithm is used to sort them, as follows:
[0102] The above evaluation scores are allocated 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 binary search to sort the data in the sub-bucket; finally, the sub-buckets are merged in turn to form the first test case priority sequence S1 = {t1, t2, t5, t4, t6, t7}.
[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 f2(t) is constructed according to the normalization result, and the expression is:
[0106]
[0107] 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;
[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] 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.
[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 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 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 = {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;
[0115] 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;
[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] Unchanged code blocks whose similarity is greater than the similarity threshold sim0 are regarded as unchanged code blocks similar to the changed code blocks.
[0120] 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.
[0121] In one example, if Figure 4 As shown, the first test case priority sequence is S1 = {t1, t2, t5, t4, t6, t7}, and the second test case priority sequence is S2 = {t1, t4, t2}. The longer sequence S1 is used as the original sequence, and the position of each element in S2 is found in S1, and the position is put into the new array S', that is, S' = [0, 3, 1]. By comparing the values in S', the minimum value 0 and the maximum value 3 are obtained. The sequence between the minimum and maximum values in S1 must contain S2. Therefore, the sequence S1[0:3] is taken out and covered with S' to obtain the shortest common subsequence S', that is, S' = [t1, t2, t5, t4].
[0122] Identify the differences between the elements in sequence S′ and sequence S2, and obtain the elements with order differences and their positions in S′, such as (t2, t4) and (t4, t2). If the code corresponding to t4 is executed before the code block corresponding to t2 during the test, adjust the order of the two test cases in S′ to [t4, t2]. Figure 4 After this part of the operation, the adjusted shortest common subsequence is replaced into the original sequence, and finally the use case priority sequence S = [t1, t4, t5, t2, t6, t7] is obtained.
[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; 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.
2. The test case priority sorting 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.
3. The test case priority sorting method based on multi-sequence fusion according to claim 2 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.
4. The test case prioritization 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; Each feature of the test case in the third test case set is 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 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; 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.
5. The test case priority sorting method based on multi-sequence fusion according to claim 2 or 4, 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.
6. The test case priority sorting method based on multi-sequence fusion according to claim 5 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.
7. 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.
8. The test case priority sorting method based on multi-sequence fusion according to claim 1 is characterized in that: The formula for calculating the similarity between the coverage targets of each test case in step 1 is: 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; The calculation expression of target coverage is:
9. The test case priority sorting method based on multi-sequence fusion according to claim 2 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 case reusing method based on code similarity
CN115237758A
Test case sorting method based on ship code coverage representation learning
CN116302983A