CN112685327A - Method for generating failure test case of model domain - Google Patents

Method for generating failure test case of model domain Download PDF

Info

Publication number
CN112685327A
CN112685327A CN202110115994.1A CN202110115994A CN112685327A CN 112685327 A CN112685327 A CN 112685327A CN 202110115994 A CN202110115994 A CN 202110115994A CN 112685327 A CN112685327 A CN 112685327A
Authority
CN
China
Prior art keywords
test case
failed
test cases
index
failed 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.)
Granted
Application number
CN202110115994.1A
Other languages
Chinese (zh)
Other versions
CN112685327B (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.)
Chongqing University
Original Assignee
Chongqing University
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 Chongqing University filed Critical Chongqing University
Priority to CN202110115994.1A priority Critical patent/CN112685327B/en
Publication of CN112685327A publication Critical patent/CN112685327A/en
Application granted granted Critical
Publication of CN112685327B publication Critical patent/CN112685327B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention relates to a method for generating a failure test case of a model domain, which comprises the steps of firstly defining a minimum suspicious set, extracting common characteristics from all failure test cases, and then carrying out variation on information with non-common characteristics on each failure test case in the model domain on the basis of keeping the common characteristics of the failure test cases so as to generate a new failure test case of the model domain. And finally, fusing the failed test cases of the newly added model domain into the original test case set and positioning the defects. The method uses a variant nearest neighbor algorithm to generate the failed test case vector of the model domain, thereby achieving the purpose of improving the defect positioning effect.

Description

Method for generating failure test case of model domain
Technical Field
The invention relates to a method for generating a failure test case, in particular to a method for generating a failure test case of a model domain.
Background
During software development and maintenance, the purpose of software debugging is to discover and repair errors that exist in the software. It is a time consuming and labor intensive process often requiring developers to devote a great deal of effort and time. To reduce the cost of debugging, researchers have proposed many ways to help the debugger find bugs in programs. A typical procedure for locating procedural defects is: assuming that there is a program P and a test case set T constructed from an input field, the program P will generate an information matrix of a model field after executing all the test cases in T, as shown in fig. 1. And then, calculating the coverage information of the model domain by using a suspicious value calculation formula, and finally obtaining a sentence suspicious value list in descending order. The coverage information of this model domain is usually represented in the form of a matrix.
The test case set T plays a crucial role in the defect location process. It contains two test cases with different characteristics: successful test cases and failed test cases. In reality, however, the number of failed test cases that lead to software failures is much smaller than the number of successful test cases. Existing research shows that failed test cases often help to locate defects. The problem of class imbalance among test cases can affect the final result of defect positioning. Therefore, in order to improve the positioning performance, it is necessary to generate more failed test cases to alleviate the category imbalance problem.
One way to generate a failed test case is to start from the input field. However, the inputs that cause a program to fail typically account for only a small portion of the input field. Therefore, researchers have made much effort to generate failed test cases, but existing test case generation methods have rarely started with generating failed test cases in view of the difficulty of generating in the input field.
Disclosure of Invention
Aiming at the problems in the prior art, the technical problems to be solved by the invention are as follows: how to generate effective test cases that can be used to locate the failure of a software bug.
In order to solve the technical problems, the invention adopts the following technical scheme: a method for generating a failed test case of a model domain,
the method comprises the following steps:
s10: acquiring data, wherein a program P containing defects is given, a group of original test cases T are provided, and the output of each test case in the group of test cases T is known;
each test case in the T is handed to the P to be executed, and statement coverage information of each test case in the program P is obtained;
meanwhile, for each test case, comparing the known output of the test case with the actual output obtained after the program P is operated, wherein if the actual output of each test case is the same as the known output, the label of the test case is 1, otherwise, the label of the test case is 0;
forming label vectors by the labels of all the test cases;
the statement coverage information and the labels of all test cases in the program P form an original coverage matrix of an original test case set, and the original coverage matrix is marked as TOrig;
s20: initializing variables, copying an original coverage matrix TOrig to an output matrix TNew, and initializing the output matrix;
finding statement coverage information and labels corresponding to the failed test cases in the original coverage matrix and the label vector, and forming a failed case coverage matrix TOrigF by the statement coverage information and the labels corresponding to all the failed test cases;
calculating the number Pnum of successful test cases, the number Fnum of failed test cases and the difference value Fnewnum between the number of successful test cases and the number of failed test cases in the original test case set, wherein the Fnewnum is Pnum-Fnum;
assigning an empirical value to the nearest neighbor number k of the program P as an initial value;
s30, finding k nearest neighbors of each failed test case, and for each failed test case, finding k failed test cases closest to the current failed test case as the nearest neighbors and storing the k failed test cases in an array nnarray;
s40, generating a failure test case on the model domain;
initializing the value of index to be 1;
s41: selecting a random integer from 1 to k, and recording the random integer as r;
s42: extracting the index-th failed test case t from TOrigFi(ii) a In the nnarrayindexIn (1), get the r nearest neighbor failed test case tr
S43: using the formula: t is ti+rand(0,1)*|tr-tiGenerating a new failure test case, and setting a label of the new failure test case as 1;
s44: recording the newly generated failure test case as tnewAnd will tnewAdding the tail end of TNew to obtain TNewindex
S45: let index have a value of index + 1; judging whether the value of the index meets the index% (Fnum +1) and is 0, if so, making the value of the index be 1, and executing the next step; if not, executing the next step;
s46: judging whether index is larger than Fnewnum, if so, returning to S41, otherwise, outputting TNewindex
As an improvement, the method for finding k failed test cases closest to the current failed test case in S30 includes: and calculating the Euclidean distances between the current failed test case and all the failed test cases, arranging the obtained Euclidean distances in a descending order, and taking the failed test cases corresponding to the first k Euclidean distances as the k nearest neighbors of the current failed test case.
Compared with the prior art, the invention has at least the following advantages:
the invention provides a method for generating a failed test case of a model domain, which uses a variant nearest neighbor algorithm to generate a failed test case vector of the model domain, thereby achieving the purpose of improving the defect positioning effect.
Drawings
Fig. 1 illustrates a typical procedure for locating a procedure defect in the prior art.
FIG. 2 is a schematic diagram of a program spectral information model of a model domain.
FIG. 3 is a diagram of a virtual test case for use in deep learning based defect localization.
Fig. 4 is a diagram of a defect localization technique based on deep learning.
Fig. 5 is an example illustrating the principle of the method of the present invention.
FIGS. 6(a) -6 (d) are comparative plots of the EXAM values for 8 defect localization methods using MTF-Gen and localization methods without MTF-Gen.
FIG. 7(a) is a RImp comparison of used MTF-Gen versus unused MTF-Gen for all subject procedures on 8 defect localization methods; FIG. 7(b) is a RImp comparison of MTF-Gen versus non-MTF-Gen for all defect localization methods in 8 subject procedures.
Detailed Description
The present invention is described in further detail below.
The invention achieves the purpose of enhancing the test case set by generating the vector of the failed test case on the coverage matrix, and two challenges are faced when the failed test case is generated on the coverage matrix.
The first is to select which information in the model domain to generate is more beneficial to improve the accuracy of the positioning. The data (smallest suspicious segment) in the model domain covering all the failed test case features has a great effect on locating defects, and the smallest suspicious segment refers to a statement covered by all the failed test cases. For a single-defect program, we can intuitively determine that the smallest suspicious segment contains a wrong statement certainly. This means that test case vectors generated from the model domain that contain the smallest suspect segment can be marked as failed test cases. Another challenge is how much data is generated. A class-balanced test case set is more advantageous for locating defects, and generally performs better than a class-unbalanced test case set. Therefore, we continue to generate failed test cases until they have the same number as the successful test cases.
The invention solves the two challenges and provides a method for generating MTF-Gen, namely a model-level failure test case. The method uses a variant nearest neighbor algorithm to generate a failure test case vector of a model domain, thereby achieving the purpose of improving the defect positioning effect. MTF-Gen uses an information model in which a vector records the execution information of a test case, showing which statements are covered by the test case. Specific values are used to represent the different weights. MTF-Gen generates new failed test cases in the model domain by covering the minimum suspicious segment with the existing failed test cases.
Specifically, for a failed test case in a model domain, MTF-Gen selects the nearest neighbor from all failed test cases and finds their intersection, which contains the set of statements covered by all failed test cases (the smallest suspect segment). To preserve common features in the intersection, the MTF-Gen generates a new failed test case by merely changing the portions of the two failed test cases that are not identical. Therefore, this new failed test case containing the smallest suspect fragment is helpful for computing defects. And finally, continuously generating new failure test cases by the MTF-Gen until a class-balanced test case set is obtained, wherein the set contains the same number of successful test cases and failure test cases.
Unlike the conventional method for generating test cases from an input field, the method for generating a failed test case vector in a model field is simpler and more effective, and a failed tag is not acquired by program execution.
A method for generating a failed test case of a model domain comprises the following steps:
s10: acquiring data, wherein a program P containing defects is given, a group of original test cases T are provided, and the output of each test case in the group of test cases T is known;
each test case in the T is handed to the P to be executed, and statement coverage information of each test case in the program P is obtained;
meanwhile, for each test case, comparing the known output of the test case with the actual output obtained after the program P is operated, wherein if the actual output of each test case is the same as the known output, the label of the test case is 1, otherwise, the label of the test case is 0;
forming label vectors by the labels of all the test cases;
the statement coverage information and the labels of all test cases in the program P form an original coverage matrix of an original test case set, which is marked as TOrig, and is shown in FIG. 2; if the program has n statements and m test cases, the dimension of the coverage matrix is m × n, the dimension of the label vector is m × 1, and the dimension of the matrix TOrig is m × (n + 1).
S20: initializing variables, copying an original coverage matrix TOrig to an output matrix TNew, and initializing the output matrix;
finding statement coverage information and labels corresponding to the failed test cases in the original coverage matrix and the label vector, and forming a failed case coverage matrix TOrigF by the statement coverage information and the labels corresponding to all the failed test cases;
calculating the number Pnum of successful test cases, the number Fnum of failed test cases and the difference value Fnewnum between the number of successful test cases and the number of failed test cases in the original test case set, wherein the Fnewnum is Pnum-Fnum;
and assigning an empirical value to the nearest neighbor number k of the program P as an initial value.
S30, finding k nearest neighbors of each failed test case, and for each failed test case, finding k failed test cases closest to the current failed test case as the nearest neighbors and storing the k failed test cases in an array nnarray; i.e. each failed test case tjAll correspond to an array n array for storing k nearest neighborsj
Specifically, the method for finding the k failed test cases closest to the current failed test case in S30 includes:
calculating the Euclidean distances between the current failed test case and all the failed test cases, and using the sequence from large to small to obtain the Euclidean distances
And (4) sequencing, wherein the failed test cases corresponding to the first k Euclidean distances are taken as k nearest neighbors of the current failed test case.
S40, a failed test case on the model domain is generated.
Initializing the value of index to be 1;
s41: selecting a random integer from 1 to k, and recording the random integer as r;
s42: extracting the index-th failed test case t from TOrigFi(ii) a In the nnarrayindexIn (1), get the r nearest neighbor failed test case tr
S43: using the formula: t is ti+rand(0,1)*|tr-tiGenerating a new failure test case, and setting a label of the new failure test case as 1;
s44: recording the newly generated failure test case as tnewAnd will tnewAdding the tail end of TNew to obtain TNewindex
S45: let index have a value of index + 1; judging whether the value of the index meets the index% (Fnum +1) and is 0, if so, making the value of the index be 1, and executing the next step; if not, executing the next step;
s46: judging whether index is larger than Fnewnum, if so, returning to S41, otherwise, outputting TNewindex
Data covering the smallest suspect set (common characteristics for all failed test cases) is advantageous for improving positioning accuracy. Intuitively, the test case will not cause the program to fail until it executes the true bug statement, so the minimum suspect set must contain the true bug statement.
If a true defect statement is overwritten in the vector labeled with a failed test case (labeled 1), then the defect localization technique may increase the suspect value of the statement. Because the newly generated test case vector contains the minimum suspicious set, the real defect statement is covered, and the test case vector is marked as a failed test case, so that the suspicious value of the suspicious statement can be improved, namely the positioning accuracy is improved.
The main idea, therefore, of MTF-Gen is to use the information vectors of existing failed test cases (those labeled with failed test case labels) to synthesize a new information vector that covers the smallest suspect set. In particular, for each failed test case, the MTF-Gen generates a new failed test case information vector from the k nearest neighbor failed test case information vectors using an oversampling technique that synthesizes a minority of data. The intersection of the k nearest neighbor failed test cases (i.e., the intersection of the features) contains the smallest suspect set. The MTF-Gen calculates the intersection of the k nearest neighbors and generates a new information vector on the basis of the intersection, wherein the new information vector contains the common characteristics of the nearest neighbors, namely the minimum suspicious set. Therefore, MTF-Gen marks this new information vector as a failed test case and adds it to the information model.
MTF-Gen should identify how many failed test cases were generated to best improve the performance of defect localization. In fact, the class-balanced test case set is more beneficial to improving the accuracy of defect positioning, and the positioning algorithm based on the class-balanced test case set is often better than the algorithm based on class imbalance in precision. Therefore, the MTF-Gen continuously generates the number of test case information vectors with failure labels in the model domain until we obtain a class-balanced test case set, where the number of failed test case vectors is equal to the number of successful test case vectors, which also means that we have the same number of failed test cases and successful test cases.
The following illustrates the principle of the method of the invention:
the principle of the information domain test case generation method MTF-Gen is further illustrated with an example. Fig. 5 shows a program P with 16 statements, P containing a defect statement s 3. The cell under each statement in the figure records the information whether the statement is covered by the test case, wherein 1 represents covered, and 0 represents uncovered. The rightmost table indicates the success or failure of the test case, 1 indicates a failed test case, and 0 indicates a successful test case. We can see that there are 6 test cases in the example, with t1 and t6 being failed test cases.
We have chosen GP02 and MLP-FL as representatives, representing the existing spectrum-based defect localization method and the deep learning-based defect localization method, respectively. Because only two failed test cases of t1 and t6 are in the test case set, they are nearest neighbors to each other. The MFT-Gen calculates the difference between t1 and t6 and the nearest neighbor and continues to generate new failed test case information vectors by the method of line 16 in algorithm 1 until the failed test case information vectors and the successful test case information vectors have the same number. In FIG. 5, t7 and t8 are two newly generated test cases that fail. Since the MTF-Gen retains the intersection of all failed test case information vectors, i.e., the minimum suspect set, the newly generated test case information vector also contains this minimum suspect set, which is defined as { s1, s2, s3, s7, s8, s9, s12, s13} in FIG. 5. Because t7 and t8 also contain the smallest suspect set, we can ignore whether such a test case is actually in the input domain, and consider it to be a test case that also fails in the model domain. We set the tags of t7 and t8 to 1 according to step S43 in the method, indicating that it is a failed test case. After adding t7 and t8 to the original test case set, we obtain a new test case set containing 4 successful test cases and 4 failed test cases.
As shown in fig. 5, there are a total of four lists in descending order. With the original test case set as input, the output of GP02 is { s7, s8, s9, s12, s10, s11, s14, s15, s16, s13, s1, s2, s3, s6, s4, s5}, and the output of MLP is { s5, s4, s16, s11, s15, s6, s13, s12, s2, s8, s9, s3, s14, s10, s1, s7 }. In the case of the new test case set added at t7 and t8 as input, the output of GP02 is { s1, s8, s14, s3, s16, s5, s10, s12, s6, s11, s9, s13, s7, s15, s2, s4}, and the output of MLP is { s7, s8, s9, s12, s10, s1, s2, s3, s13, s14, s11, s15, s16, s5, s4, s6 }. We can see that with the original test case as input, the ranking of the localization model of the defect statement s3 in GP02 and MLP-FL is 13 th and 12 th, respectively. After using the new test case set generated by MTF-Gen, GP02(MTF-Gen) and MLP (MTF-Gen) ranked defect statement s3 at 8 th and 7 th, respectively, and better defect localization accuracy was obtained.
And (3) experimental verification:
the selected data set comes from three websites, which comprise 8 programs, each program has different defect versions and is a real defect, wherein the python, gzip and libtiff programs are from ManyBugs, http:// repairbenchmarks. The space program is derived from SIR (http:// SIR. unl. edu/portal/index. php); the chart, math, lang, and time programs are from Defect4J (http:// deffects 4j. org.). Table 1 describes the characteristics of these procedures.
TABLE 1 characteristics of the subjects
Name of program Brief description of the drawings Number of versions Code line number (thousands of lines) Number of test cases
python General procedure 8 407 355
gzip Data compression 5 491 12
libtiff Image processing 12 77 78
space ADL interpreter 35 6.1 13585
chart JFreeChart package 26 96 2205
math Math package 106 85 3602
mockito Unit test frame 38 6 1075
time Joda-Time program package 27 53 4130
In order to verify the effectiveness of the present invention, the method was applied to 8 most advanced defect localization methods and compared to the effect of defect localization methods that did not employ the method. The method comprises 2 defect positioning methods based on deep learning (see fig. 3 and 4) and 6 defect positioning methods based on program spectrum. The calculation formulas of the 6 defect localization methods based on the program spectrum are shown in table 2. The 2 defect positioning methods based on deep learning are CNN-FL and MLP-FL, and a convolutional neural network and a multilayer perceptron are respectively used as components of a deep learning component layer.
TABLE 2 suspicious value calculation formula
Figure BDA0002920461440000081
The method for generating the failure test case of the model domain is abbreviated as MTF-Gen.
Two widely used evaluation criteria will be used here: EXAM and RImp. An EXAM is defined as the percentage of statements that have been examined when a true error statement was found. A lower value of EXAM indicates better defect localization performance. RImp is defined as the sum of all statements checked for errors that MTF-Gen finds for all versions of a program divided by the sum of all statements checked for errors that another defect localization method finds for all versions of the program. For MTF-Gen, lower RImp values represent better localization performance.
The experimental results show that under the EXAM standard, the curve of the defect localization method using MTF-Gen is always above the curve of the defect localization method without MTF-Gen, which indicates that MTF-Gen improves the efficiency of the defect localization technology.
Under the RImp criteria, all scores for RImp were below 100% for all defect localization methods. This indicates that the efficacy of MTF-Gen localization on all experimental procedures was improved for each defect localization method. Taking MLP-FL as an example, RImp score was 63.17%, indicating that MLP-FL using MTF-Gen examined 63.17% of the total number of sentences that MLP-FL without MTF-Gen examined when all defects of 8 subject procedures were examined. In other words, the number of sentences to be examined when all defects were examined in all the subject programs was reduced by 36.83% (100% -63.17%: 36.83%) compared to the MLP-FL using MTF-Gen and the MLP-FL without MTF-Gen. We can see that RImp scores using MTF-Gen range from 49.63% for GP03 to 98.11% for ER 5. This means that the savings of statements using the defect localization method of MTF-Gen are at most 50.37% (100% -49.63% ═ 50.37%) of GP03 and at least 1.89% (100% -98.11% ═ 1.89%) of ER 5. All scores for RImp were below 100% in all experimental procedures, which means that MTF-Gen had an increase in localization performance over all experimental procedures. Taking chart as an example, the RImp score is 68.71%, which means that on the chart program, the total number of sentences to be checked when all versions of the chart are checked by using 8 defect positioning methods by using MTF-Gen is 68.71% of the total number of sentences to be checked when all versions of the chart are checked by not using MTF-Gen. This also means that MTF-Gen can save 31.29% (100% -68.71% ═ 31.29%) of the number of statements to be checked on the program object chart. The RImp values of MTF-Gen on all subject procedures ranged from 52.09% for mockito to 98.92% for libtiff, indicating that the greatest savings of MTF-Gen on subject procedures were 47.91% (100% -52.09% ═ 47.91%) for mockito and the smallest savings were 1.08% (100% -98.92% ═ 1.08%) for libtiff.
Overall, the MTF-Gen savings averaged 23.53% over all defect localization methods and over all subject procedures. Therefore, based on RImp, it can be seen that the efficiency of defect localization is significantly improved after MTF-Gen is used.
To further validate the effectiveness of the invention, we used the Wilcoxon signed rank test for statistical analysis, since RImp only demonstrates specific scale of boost, it is only an overall effect boost demonstration, and some specific details may be missed. Wilcoxon signed rank test non-parametric statistics were used to test the difference between a pair of data F (x) and G (y) that did not follow a normal distribution. Given a parameter σ, we use the p-values of 2-tailed and 1-tailed to reach a conclusion. For a p value of 2-tailed, assume that p ≧ σ, accept hypothesis H0: f (x) and G (y) are not significantly different. Otherwise, accept hypothesis H1: f (x) and G (y) are significantly different. There are two cases for a p value of 1-tailed: 1-tailed (right) and 1-tailed (left), respectively. For 1-tailed (right), if p ≧ σ, assume H0: f (x) and G (y) compare results not accepted by Better; otherwise assume H1: f (x) and G (y) compare to result in acceptance of Better. For 1-tailed (left), if p ≧ σ, assume H0: f (x) and G (y) compare results not accepted as Worse; otherwise assume that H1 compares F (x) to G (y) with a result of Worse being accepted.
FIGS. 6(a) -6 (d) show a comparison of the EXAM values for 8 defect localization methods using MTF-Gen and localization methods without MTF-Gen. In fig. 6(a) -6 (d), the abscissa represents the percentage of sentences that have been inspected, and the ordinate represents the percentage of the number of defect versions that have been found among the number of versions with all defects. One point in "fig. 6(a) -fig. 6(d) indicates the percentage of the total number of defects that have been detected when a certain proportion of the sentence has been detected. It can be seen from FIGS. 6(a) -6 (d) that the curves for the defect localization method using MTF-Gen are always above the curves for the defect localization method without MTF-Gen, indicating that MTF-Gen enhances the efficacy of the defect localization technique.
To further demonstrate the results of the experiment, we used RImp to evaluate the effectiveness of MTF-Gen. FIG. 7 shows RImp contrast plots using MTF-Gen for both cases, FIG. 7(a) is RImp contrast using MTF-Gen versus unused MTF-Gen for all subject procedures on 8 defect localization methods, and FIG. 7(b) is RImp contrast using MTF-Gen versus unused MTF-Gen for all defect localization methods on 8 subject procedures.
As shown in FIG. 7(a), all scores of RImp were below 100% in all defect localization methods. This indicates that the efficacy of MTF-Gen localization on all experimental procedures was improved for each defect localization method. Taking MLP-FL as an example, RImp score was 63.17%, indicating that MLP-FL using MTF-Gen examined 63.17% of the total number of sentences that MLP-FL without MTF-Gen examined when all defects of 8 subject procedures were examined. In other words, the number of sentences to be examined when all defects were examined in all the subject programs was reduced by 36.83% (100% -63.17%: 36.83%) compared to the MLP-FL using MTF-Gen and the MLP-FL without MTF-Gen. We can see that RImp scores using MTF-Gen range from 49.63% for GP03 to 98.11% for ER 5. This means that the savings of statements using the defect localization method of MTF-Gen are at most 50.37% (100% -49.63% ═ 50.37%) of GP03 and at least 1.89% (100% -98.11% ═ 1.89%) of ER 5.
In FIG. 7(b), all scores for RImp were below 100% in all experimental procedures, which means that MTF-Gen had an increase in localization performance in all experimental procedures. Taking chart as an example, the RImp score is 68.71%, which means that on the chart program, the total number of sentences to be checked when all versions of the chart are checked by using 8 defect positioning methods by using MTF-Gen is 68.71% of the total number of sentences to be checked when all versions of the chart are checked by not using MTF-Gen. This also means that MTF-Gen can save 31.29% (100% -68.71% ═ 31.29%) of the number of statements to be checked on the program object chart. The RImp values of MTF-Gen on all subject procedures ranged from 52.09% for mockito to 98.92% for libtiff, indicating that the greatest savings of MTF-Gen on subject procedures were 47.91% (100% -52.09% ═ 47.91%) for mockito and the smallest savings were 1.08% (100% -98.92% ═ 1.08%) for libtiff.
In the experiment, we compared the Wilcoxon signed rank test for 8 defect localization methods, both with and without MTF-Gen. The experiment used EXAM as a reference to compare F (x) and G (y), each using 2-tailed and 1-tailed assays with a. of 0.05. In particular, assuming a defect localization method FL1, we assume a series of EXAM values for the FL1 of MTF-Gen over all defect versions of all procedures as F (x), and a series of EXAM values for the FL1 of MTF-Gen over all defect versions of all procedures as G (y). Thereafter, in the 2-tailed assay, FL1 using MTF-Gen and FL1 without MTF-Gen had SIMILAR localization potency when receiving H0 with a significance level σ of 0.05, resulting in SIMILAR. In the 1-tailed (right) assay, when H1 with a significance level σ of 0.05 was received, the localization potency of FL1 using MTF-Gen was inferior to FL1 without MTF-Gen, resulting in WORSE. In the 1-tailed (left) assay, FL1 using MTF-Gen performed BETTER than FL1 without MTF-Gen when receiving H1 with a significance level σ of 0.05, resulting in BETTER.
In short, the invention provides a method for generating the failed test case of the model domain, which has reasonable and sufficient interpretability. The method provided by the invention is applied to the current mainstream defect positioning method, can obviously improve the positioning accuracy, can be applied to an actual application scene, and contributes to improving the efficiency of finding the defect position by developers.
TABLE 3 Wilcoxon signed rank test
Figure BDA0002920461440000111
Table 3 summarizes the Wilcoxon signed rank test comparison across all defect localization methods and the Wilcoxon signed rank test comparison across all experimental procedure subjects. For example, in comparison of defect localization methods, MLP-FL (MTF-Gen) and MLP-FL were compared, and MLP (MTF-Gen) obtained 8 BETTERs (8/8 ═ 100%). In the comparison over the experimental procedure, gzip (MTF-Gen) obtained 4 letters (4/8 ═ 50%), 4 SIMILAR (4/8 ═ 50%), and 0 WORSE (0/8 ═ 0%), compared to gzip. As can be seen from table 3, MTF-Gen obtained 76 letters (76/128 ═ 59.37%), 52 SIMILARs (52/127 ═ 40.63%) and 0 WORSE in total. Therefore, based on the above results and analysis, we can conclude that MTF-Gen significantly enhances the efficacy of defect localization, showing the potential for generating test cases from models.
Finally, the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all of them should be covered in the claims of the present invention.

Claims (2)

1. A method for generating a failed test case of a model domain is characterized by comprising the following steps:
s10: acquiring data, wherein a program P containing defects is given, a group of original test cases T are provided, and the output of each test case in the group of test cases T is known;
each test case in the T is handed to the P to be executed, and statement coverage information of each test case in the program P is obtained;
meanwhile, for each test case, comparing the known output of the test case with the actual output obtained after the program P is operated, if the actual output of the test case is the same as the known output, the label of the test case is 1, otherwise the label of the test case is 0;
forming label vectors by the labels of all the test cases;
the statement coverage information and the labels of all test cases in the program P form an original coverage matrix of an original test case set, and the original coverage matrix is marked as TOrig;
s20: initializing variables, copying an original coverage matrix TOrig to an output matrix TNew, and initializing the output matrix;
finding statement coverage information and labels corresponding to the failed test cases in the original coverage matrix and the label vector, and forming a failed case coverage matrix TOrigF by the statement coverage information and the labels corresponding to all the failed test cases;
calculating the number Pnum of successful test cases, the number Fnum of failed test cases and the difference value Fnewnum between the number of successful test cases and the number of failed test cases in the original test case set, wherein the Fnewnum is Pnum-Fnum;
assigning an empirical value to the nearest neighbor number k of the program P as an initial value;
s30, finding k nearest neighbors of each failed test case, and for each failed test case, finding k failed test cases closest to the current failed test case as the nearest neighbors and storing the k failed test cases in an array nnarray;
s40, generating a failure test case on the model domain;
initializing the value of index to be 1;
s41: selecting a random integer from 1 to k, and recording the random integer as r;
s42: extracting the index-th failed test case t from TOrigFi(ii) a In the nnarrayindexIn (1), get the r nearest neighbor failed test case tr
S43: using the formula: t is ti+rand(0,1)*|tr-tiGenerating a new failure test case, and setting a label of the new failure test case as 1;
s44: recording the newly generated failure test case as tnewAnd will tnewAdding the tail end of TNew to obtain TNewindex
S45: let index have a value of index + 1; judging whether the value of the index meets the index% (Fnum +1) and is 0, if so, making the value of the index be 1, and executing the next step; if not, executing the next step;
s46: judging whether index is larger than Fnewnum, if so, returning to S41, otherwise, outputting TNewindex
2. The method for generating the failed test case of the model domain according to claim 1, wherein: the method for finding the k failed test cases closest to the current failed test case in S30 includes:
and calculating the Euclidean distances between the current failed test case and all the failed test cases, arranging the obtained Euclidean distances in a descending order, and taking the failed test cases corresponding to the first k Euclidean distances as the k nearest neighbors of the current failed test case.
CN202110115994.1A 2021-01-28 2021-01-28 Method for generating failure test case of model domain Active CN112685327B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110115994.1A CN112685327B (en) 2021-01-28 2021-01-28 Method for generating failure test case of model domain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110115994.1A CN112685327B (en) 2021-01-28 2021-01-28 Method for generating failure test case of model domain

Publications (2)

Publication Number Publication Date
CN112685327A true CN112685327A (en) 2021-04-20
CN112685327B CN112685327B (en) 2023-06-27

Family

ID=75459414

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110115994.1A Active CN112685327B (en) 2021-01-28 2021-01-28 Method for generating failure test case of model domain

Country Status (1)

Country Link
CN (1) CN112685327B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113836027A (en) * 2021-09-28 2021-12-24 重庆大学 Method for generating failure test case by using generating network
CN114416845A (en) * 2022-01-19 2022-04-29 平安好医投资管理有限公司 Big data testing method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103019943A (en) * 2013-01-04 2013-04-03 北京航空航天大学 Software error positioning method catering to rare case of failed test cases
US20130159963A1 (en) * 2011-12-15 2013-06-20 Tata Consultancy Services Limited Agile Unit and Regression Testing Framework for Domain Specific Languages
CN103970676A (en) * 2013-01-29 2014-08-06 帝斯贝思数字信号处理和控制工程有限公司 Computer-implemented method and system for data management of product variants in control unit development
CN105117331A (en) * 2015-08-17 2015-12-02 浪潮(北京)电子信息产业有限公司 Error-location-oriented coincidence correctness test case identification method and device
CN106909502A (en) * 2017-01-13 2017-06-30 河南工业大学 Accidental correctness test case recognition methods and software error localization method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130159963A1 (en) * 2011-12-15 2013-06-20 Tata Consultancy Services Limited Agile Unit and Regression Testing Framework for Domain Specific Languages
CN103019943A (en) * 2013-01-04 2013-04-03 北京航空航天大学 Software error positioning method catering to rare case of failed test cases
CN103970676A (en) * 2013-01-29 2014-08-06 帝斯贝思数字信号处理和控制工程有限公司 Computer-implemented method and system for data management of product variants in control unit development
CN105117331A (en) * 2015-08-17 2015-12-02 浪潮(北京)电子信息产业有限公司 Error-location-oriented coincidence correctness test case identification method and device
CN106909502A (en) * 2017-01-13 2017-06-30 河南工业大学 Accidental correctness test case recognition methods and software error localization method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
JOSÉ CARLOS BREGIEIRO RIBEIRO 等: ""Test Case Evaluation and Input Domain Reduction strategies for the Evolutionary Testing of Object-Oriented software"", 《INFORMATION AND SOFTWARE TECHNOLOGY》, vol. 51, no. 11, pages 1534 - 1548 *
尤枫 等: ""基于输出域的测试用例自动生成方法研究"", 《计算机研究与发展》, pages 541 - 549 *
张卓 等: ""增强上下文的错误定位技术"", 《软件学报》, pages 266 - 281 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113836027A (en) * 2021-09-28 2021-12-24 重庆大学 Method for generating failure test case by using generating network
CN113836027B (en) * 2021-09-28 2023-07-21 重庆大学 Method for generating failure test case by using generation type network
CN114416845A (en) * 2022-01-19 2022-04-29 平安好医投资管理有限公司 Big data testing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112685327B (en) 2023-06-27

Similar Documents

Publication Publication Date Title
CN112685327A (en) Method for generating failure test case of model domain
US20160196021A1 (en) Automated Modularization of Graphical User Interface Test Cases
WO2022027913A1 (en) Target detection model generating method and apparatus, device and storage medium
CN112231133B (en) Data restoration processing method and device and electronic equipment
CN1667622A (en) Design verification using formal techniques
CN118012767B (en) Multi-coverage-rate-use-case-oriented generation and multi-method-fusion-oriented software bug positioning method
CN114936158A (en) Software defect positioning method based on graph convolution neural network
CN111581086A (en) Hybrid software error positioning method and system based on RankNet
CN110674044B (en) Coverage rate acquisition method, system, equipment and medium for function automation test
CN115061908A (en) Method and device for positioning defect code, storage medium and computer equipment
CN111309596A (en) Database testing method and device, terminal equipment and storage medium
US10152407B1 (en) Optimization of analysis of automated test results
Maksimovic et al. Clustering-based revision debug in regression verification
CN109032932B (en) Constraint-supported combined test fault positioning method
CN109144793B (en) Fault correction device and method based on data flow driving calculation
US11556460B2 (en) Test case generation for software development using machine learning
US11899566B1 (en) Training and/or using machine learning model(s) for automatic generation of test case(s) for source code
CN115481406A (en) Program bug fixing method and device, electronic equipment and storage medium
US10769332B2 (en) Automatic simulation failures analysis flow for functional verification
CN110096447B (en) Software and hardware automatic testing method based on image recognition
CN117561502A (en) Method and device for determining failure reason
CN117313900B (en) Method, apparatus and medium for data processing
CN117313899B (en) Method, apparatus and medium for data processing
CN113836027B (en) Method for generating failure test case by using generation type network
CN113434386B (en) Method, system and storage medium for fuzz testing

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