CN109254924B - Software fault positioning method, device, equipment and readable storage medium - Google Patents

Software fault positioning method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN109254924B
CN109254924B CN201811144869.8A CN201811144869A CN109254924B CN 109254924 B CN109254924 B CN 109254924B CN 201811144869 A CN201811144869 A CN 201811144869A CN 109254924 B CN109254924 B CN 109254924B
Authority
CN
China
Prior art keywords
test case
statement
test cases
fault
correct
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811144869.8A
Other languages
Chinese (zh)
Other versions
CN109254924A (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.)
Changchun Institute of Optics Fine Mechanics and Physics of CAS
Original Assignee
Changchun Institute of Optics Fine Mechanics and Physics of CAS
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 Changchun Institute of Optics Fine Mechanics and Physics of CAS filed Critical Changchun Institute of Optics Fine Mechanics and Physics of CAS
Priority to CN201811144869.8A priority Critical patent/CN109254924B/en
Publication of CN109254924A publication Critical patent/CN109254924A/en
Application granted granted Critical
Publication of CN109254924B publication Critical patent/CN109254924B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a software fault positioning method, which comprises the steps of firstly calculating the doubtful degree of each correct test case in a test case set in the process of positioning a fault statement in a program to be tested, and calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases; and according to the number of the accidental correct test cases, the number of the covered and successful test cases and the number of the covered and failed test cases corresponding to each statement are respectively adjusted, and then the Ochiai method is adopted to position the fault statement in the program to be tested, so that the difference between the fault suspected value and the true value of the statement is reduced, the accuracy of fault judgment of each statement in the program to be tested is improved, and the software fault positioning efficiency and the working efficiency of technical personnel are also improved. Correspondingly, the software fault positioning device, the equipment and the readable storage medium disclosed by the invention also have the technical effects.

Description

Software fault positioning method, device, equipment and readable storage medium
Technical Field
The invention relates to the technical field of software testing, in particular to a software fault positioning method, a device, equipment and a readable storage medium.
Background
Software testing is a process of testing the functions and performance of a product according to a test scheme and a flow by using a test tool. In order to track and locate software faults, a large number of test cases need to be input into a program to be tested, the output execution result is analyzed, and the program to be tested is optimized, so that the developed product is suitable for requirements.
In the prior art, the test cases in the test case set for the test program include correct test cases and incorrect test cases, and there are accidental correct test cases in the correct test cases. Research has shown that occasional correct test cases are ubiquitous in the test case collection, even accounting for over 90% of test cases.
The accidental correct test case refers to a case with the following characteristics: its execution covers the fault statement of the program, but the output of the program is correct. According to the pie (propagation Infection execution) model, it can be known that: if the test case trigger software fails, 3 conditions must be satisfied:
(1) executing the test case to a fault statement;
(2) the execution of the fault statement causes a subsequent program internal state to be in error;
(3) the internal state of the error affects the output of the program through propagation.
The contingent correctness test case only satisfies the condition (1) and/or the condition (2), but does not satisfy the condition (3). It can be analyzed that the accidental correct test case does not cause the output of the program error, and the two reasons are as follows: the test case covers the failure statement, but the error is not activated; the test case covers the fault statement and the error is activated, but the error is reflected to the output of the program because of the occurrence of: the error result happens to be in the interval that the test case can pass successfully; erroneous results are flushed or masked by subsequent statements.
At present, in the process of positioning software faults, the influence of accidental correct test cases on positioning results is not considered, so that the fault suspected value of a statement determined by the conventional software fault positioning method is smaller than a real value, and the accuracy and efficiency of fault positioning are influenced. In the existing software fault location method, only the different information quantities of the test cases which are successfully executed and the test cases which are failed to be executed for fault location are considered, and the different effective information quantities of the same test case for the fault location of different statements are considered.
Therefore, how to weaken the negative influence of the contingency correct test case on the software fault location is a problem to be solved by those skilled in the art.
Disclosure of Invention
The invention aims to provide a software fault positioning method, a device, equipment and a readable storage medium, which are used for weakening the negative influence of accidental correct test cases on software fault positioning.
In order to achieve the above purpose, the embodiment of the present invention provides the following technical solutions:
a software fault locating method comprises the following steps:
acquiring a program to be tested and a test case set, testing the program to be tested by using each test case in the test case set, and acquiring a statement spectrum and an execution result corresponding to each test case;
respectively determining a covered and successful test case, a covered and failed test case, an uncovered and successful test case and an uncovered and failed test case corresponding to each statement in the program to be tested according to the obtained statement spectrum and the execution result;
determining the suspected degree of each correct test case in the test case set, and calculating the number of accidental correct test cases in the test case set according to the suspected degrees of all correct test cases;
and respectively adjusting the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of accidental correct test cases, and positioning the fault statement in the program to be tested by adopting an Ochiai method based on the uncovered and successful test cases, the uncovered and failed test cases, the adjusted covered and successful test cases and the adjusted covered and failed test cases corresponding to each statement.
The determining the doubtful degree of each correct test case in the test case set comprises the following steps:
for each correct test case, the following steps are respectively adopted to determine the doubtful degree:
calculating the similarity between the statement spectrum of the target correct test case in the test case set and the statement spectrum of each wrong test case in the test case set by using the Jaccard coefficient to obtain a similarity set;
and determining the maximum similarity in the similarity set, and taking the maximum similarity as the doubtful degree of the target correct test case.
The method for calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases comprises the following steps:
and taking the sum of the doubtful degrees of all correct test cases as the number of the accidental correct test cases.
Wherein, according to the number of the correct test cases of the contingency, respectively adjust the number of the test cases of covering and success and the number of the test cases of covering and failure corresponding to each statement, including:
and reducing the number of covered and successful test cases corresponding to each statement by N, and increasing the number of covered and failed test cases by N, wherein N represents the number of accidental correct test cases.
The method for locating the fault statement in the program to be tested by adopting the Ochiai method comprises the following steps:
calculating a fault suspected value of each statement by adopting an Ochiai method;
and arranging all sentences in the program to be tested in a descending or ascending order according to the size of the fault suspected value to form a fault sentence sequence, and positioning the fault sentences according to the fault sentence sequence.
Wherein, still include:
when the suspected fault values of a plurality of sentences are the same, determining the suspected fault value weight of each sentence;
correcting the fault suspected value of each statement by using the fault suspected value weight of each statement to obtain a plurality of corrected fault suspected values;
and arranging a plurality of sentences with the same fault suspected value according to the size of the corrected fault suspected value.
Before determining the doubtful degree of each correct test case in the test case set, the method further comprises the following steps:
and calculating a correction coefficient corresponding to each statement, and correspondingly correcting each statement spectrum by using the correction coefficient corresponding to each execution statement.
A software fault locating device comprising:
the acquisition module is used for acquiring a program to be tested and a test case set, testing the program to be tested by using each test case in the test case set and acquiring a statement spectrum and an execution result corresponding to each test case;
the determining module is used for respectively determining a covered and successful test case, a covered and failed test case, an uncovered and successful test case and an uncovered and failed test case corresponding to each statement in the program to be tested according to the obtained statement spectrum and the execution result;
the calculation module is used for determining the doubtful degree of each correct test case in the test case set and calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases;
and the positioning module is used for respectively adjusting the number of the covered and successful test cases and the number of the covered and failed test cases corresponding to each statement according to the number of the accidental correct test cases, and positioning the fault statement in the program to be tested by adopting an Ochiai method based on the uncovered and successful test cases, the uncovered and failed test cases, the adjusted covered and successful test cases and the adjusted covered and failed test cases corresponding to each statement.
A software fault locating device comprising:
a memory for storing a computer program;
a processor for implementing the steps of the software fault location method of any one of the above when executing the computer program.
A readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the software fault localization method of any one of the above.
According to the scheme, the software fault positioning method provided by the embodiment of the invention comprises the following steps: acquiring a program to be tested and a test case set, testing the program to be tested by using each test case in the test case set, and acquiring a statement spectrum and an execution result corresponding to each test case; respectively determining a covered and successful test case, a covered and failed test case, an uncovered and successful test case and an uncovered and failed test case corresponding to each statement in the program to be tested according to the obtained statement spectrum and the execution result; determining the suspected degree of each correct test case in the test case set, and calculating the number of accidental correct test cases in the test case set according to the suspected degrees of all correct test cases; and respectively adjusting the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of accidental correct test cases, and positioning the fault statement in the program to be tested by adopting an Ochiai method based on the uncovered and successful test cases, the uncovered and failed test cases, the adjusted covered and successful test cases and the adjusted covered and failed test cases corresponding to each statement.
It can be seen that, in the process of locating a fault statement in a program to be tested, the method firstly calculates the doubtful degree of each correct test case in the test case set, and calculates the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases; and according to the number of the accidental correct test cases, the number of the covered and successful test cases and the number of the covered and failed test cases corresponding to each statement are respectively adjusted, and then the Ochiai method is adopted to position the fault statement in the program to be tested, so that the difference between the fault suspected value and the true value of the statement is reduced, the accuracy of fault judgment of each statement in the program to be tested is improved, and the software fault positioning efficiency and the working efficiency of technical personnel are also improved.
Accordingly, the software fault locating device, the equipment and the readable storage medium provided by the embodiment of the invention also have the technical effects.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of a software fault location method according to an embodiment of the present invention;
FIG. 2 is a flowchart of another software fault location method disclosed in the embodiments of the present invention;
FIG. 3 is a schematic diagram of a software fault locating apparatus according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a software fault locating apparatus according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a test case set according to an embodiment of the present invention;
FIG. 6 is a flowchart of a software fault location method according to an embodiment of the present invention;
FIG. 7 is a flow chart of sentence spectrum modification disclosed in the embodiments of the present invention;
fig. 8 is a flowchart for determining the number of chance correct test cases according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention discloses a software fault positioning method, a device, equipment and a readable storage medium, which are used for weakening the negative influence of accidental correct test cases on software fault positioning.
Referring to fig. 1, a software fault location method provided in an embodiment of the present invention includes:
s101, acquiring a program to be tested and a test case set, testing the program to be tested by using each test case in the test case set, and acquiring a statement spectrum and an execution result corresponding to each test case;
it should be noted that the test case set is composed of correct test cases and incorrect test cases, where the correct test cases include accidental correct test cases. And executing the program to be tested one by using each test case in the test case set, and recording whether each statement in the program to be tested is covered by each test case and a corresponding execution result by using a preset covering mark value.
The correct test case, namely the test case which is successfully executed, comprises the following steps: covered and successful test cases and uncovered and successful test cases; the test case with the error, namely the test case with the execution failure, comprises the following steps: covered and failed test cases and uncovered and failed test cases.
For example: the program to be tested comprises A, B, C three sentences, and the test case set comprises a test case a, a test case b and a test case c; a flag value covering the current statement is represented by 1, and a flag value not covering the current statement is represented by 0; the execution results of the test cases a, b and c executing the program to be tested are respectively as follows: success, failure, success; then the statement spectrum and the execution result respectively corresponding to the test cases a, b and c are as follows:
the statement spectrum corresponding to the test case a is {1, 1, 0}, which means that the test case a covers statements A and B in the program to be tested and does not cover statement C; the execution result of the whole test case a to-be-tested program is as follows: success is achieved;
the statement spectrum corresponding to the test case B is {1, 0, 0}, which means that the test case B covers statement A in the program to be tested and does not cover statements B and C; the execution result of the whole test case b on the program to be tested is as follows: failure;
the statement spectrum corresponding to the test case C is {0, 1, 1}, which means that the test case C covers statements B and C in the program to be tested and does not cover statement A; the execution result of the whole test case c on the program to be tested is as follows: and (4) success.
To sum up, after the test cases a, b, and c are used to execute the program to be tested, please refer to the following table for the relationship between the test cases and the statements in the program to be tested:
Figure BDA0001815332080000061
s102, respectively determining a covered and successful test case, a covered and failed test case, an uncovered and successful test case and an uncovered and failed test case corresponding to each statement in the program to be tested according to the obtained statement spectrum and the execution result;
in combination with the above example, the statements A, B, C in the program to be tested correspond to the covered and successful test cases respectively, and the covered and failed test cases, the uncovered and successful test cases, and the uncovered and failed test cases are as follows:
the covered and successful test case corresponding to statement a is: the test case a, the covered and failed test case is: and b, testing case b, wherein the uncovered and successful testing case is as follows: a test case c, no uncovered and failed test case;
the covered and successful test case corresponding to statement B is: the test cases a and c are uncovered and failed test cases, and uncovered and successful test cases, wherein the uncovered and failed test cases are as follows: a test case b;
the covered and successful test case corresponding to statement C is: a test case c, a test case without coverage and failing, the test case without coverage and succeeding being: a test case a, wherein the uncovered and failed test case is as follows: and (5) testing a case b.
S103, determining the doubtful degree of each correct test case in the test case set, and calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases;
in this embodiment, for each correct test case, the similarity between the correct test case and each wrong test case in the test case set is calculated, and the maximum similarity is determined as the doubtful degree of the correct test case. Because the test case set has a plurality of correct test cases, each correct test case corresponds to a maximum similarity, namely a doubtful degree, and the sum of the doubtful degrees of all the correct test cases is used as the number of accidental correct test cases in the test case set.
S104, respectively adjusting the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of accidental correct test cases;
s105, based on the uncovered and successful test case, the uncovered and failed test case, the adjusted covered and successful test case and the adjusted covered and failed test case corresponding to each statement, adopting an Ochiai method to position the fault statement in the program to be tested.
Specifically, the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement are respectively adjusted according to the number of accidental correct test cases, and then the Ochiai method is adopted to position the fault statement in the program to be tested, so that the negative influence of the accidental correct test cases on the software fault positioning can be weakened.
It can be seen that, in the process of locating a fault statement in a program to be tested, the method first calculates the suspicion degree of each correct test case in a test case set, and calculates the number of accidental correct test cases in the test case set according to the suspicion degrees of all correct test cases; and according to the number of the accidental correct test cases, the number of the covered and successful test cases and the number of the covered and failed test cases corresponding to each statement are respectively adjusted, and then the Ochiai method is adopted to position the fault statement in the program to be tested, so that the difference between the fault suspected value and the true value of the statement is reduced, the accuracy of fault judgment of each statement in the program to be tested is improved, and the software fault positioning efficiency and the working efficiency of technical personnel are also improved.
The embodiment of the invention discloses another software fault positioning method, and compared with the previous embodiment, the technical scheme is further explained and optimized by the embodiment.
Referring to fig. 2, another software fault location method provided in the embodiment of the present invention includes:
s201, acquiring a program to be tested and a test case set, testing the program to be tested by using each test case in the test case set, and acquiring a statement spectrum and an execution result corresponding to each test case;
s202, respectively determining a covered and successful test case, a covered and failed test case, an uncovered and successful test case and an uncovered and failed test case corresponding to each statement in the program to be tested according to the obtained statement spectrum and the execution result;
s203, calculating a correction coefficient corresponding to each statement, and correspondingly correcting each statement spectrum by using the correction coefficient corresponding to each execution statement;
in this embodiment, to more accurately distinguish between contingent test cases, each statement spectrum is first modified before determining the plausibility of each correct test case. The method specifically comprises the following steps: and calculating a correction coefficient corresponding to each statement, and correcting the coverage mark value in each statement spectrum by using the calculated correction coefficient to obtain a corrected statement spectrum.
Calculating a correction coefficient by adopting the following steps aiming at each statement; determining the ratio of the number of covered and failed test cases corresponding to the target statement in the program to be tested to the number of failed test cases as a correction coefficient corresponding to the target statement; wherein, the failed test case comprises: uncovered and failed test cases and covered and failed test cases.
For example: for test case tiCovered statement EjThe following formula is used for Ps (t)i) Correcting to generate a corrected term spectrum Ps+(ti)=(c1,c2,…,cj,…,cm)。
Figure BDA0001815332080000091
Figure BDA0001815332080000092
I.e. the correction factor.
Wherein, tiRepresenting a test case, test case t before correctioniCorrespond toThe statement spectrum of (1) is: ps (t)i)={e1,e2,…,ej,…,em},ej(j is not less than 1 and not more than m) is 0 and 1, and represents a test case tiWhether to cover statement Ej,EjDenotes a certain statement, ejAn override tag value representing each statement, cjIndicating the corrected overlay mark value.
nfIndicating the number of failed test cases, ncf(ej) Representing an overlay statement EjNumber of failed test cases, nuf(ej) Representing an uncovered statement EjThe number of failed test cases.
S204, determining the doubtful degree of each correct test case in the test case set according to the corrected statement spectrum, and calculating the number of accidental correct test cases in the test case set according to the doubtful degrees of all correct test cases;
s205, respectively adjusting the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of accidental correct test cases;
s206, based on the uncovered and successful test case, the uncovered and failed test case, the adjusted covered and successful test case and the adjusted covered and failed test case corresponding to each statement, adopting an Ochiai method to position the fault statement in the program to be tested.
It can be seen that, in the process of locating a fault statement in a program to be tested, the method firstly corrects the statement spectrum, calculates the suspiciousness of each correct test case in the test case set according to the corrected statement spectrum, and calculates the number of accidental correct test cases in the test case set according to the suspiciousness of all correct test cases; and according to the number of the accidental correct test cases, the number of the covered and successful test cases and the number of the covered and failed test cases corresponding to each statement are respectively adjusted, and then the Ochiai method is adopted to position the fault statement in the program to be tested, so that the difference between the fault suspected value and the true value of the statement is reduced, the accuracy of fault judgment of each statement in the program to be tested is improved, and the software fault positioning efficiency and the working efficiency of technical personnel are also improved.
Based on any of the above embodiments, it should be noted that determining the plausibility of each correct test case in the test case set includes:
for each correct test case, the following steps are respectively adopted to determine the doubtful degree:
calculating the similarity between the statement spectrum of the target correct test case in the test case set and the statement spectrum of each wrong test case in the test case set by using the Jaccard coefficient to obtain a similarity set;
and determining the maximum similarity in the similarity set, and taking the maximum similarity as the doubtful degree of the target correct test case.
Specifically, Pc is calculated by using the generalized Jaccard coefficient+(ti) And Pc+(tj) As the test case tiAnd tjIs measured by the degree of similarity Sim (t)i,tj) The similarity calculation formula is as follows:
Figure BDA0001815332080000101
wherein Pc+(ti) Indicating a corrected statement spectrum, Pc, corresponding to the correct test case+(tj) And representing a corrected statement spectrum corresponding to the error test case.
Based on any of the above embodiments, it should be noted that calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases includes:
and taking the sum of the doubtful degrees of all correct test cases as the number of the accidental correct test cases.
For correct test case ti(1≤i≤n),tiCorrect test case suspicion Scc (t) for chancei) Is tiMaximum of similarity to all false test cases, suspicion Scc (t)i) The calculation formula is as follows:
Figure BDA0001815332080000102
based on any of the above embodiments, it should be noted that, according to the number of the accidental correct test cases, the number of the covered and successful test cases and the number of the covered and failed test cases corresponding to each statement are respectively adjusted, including:
and reducing the number of covered and successful test cases corresponding to each statement by N, and increasing the number of covered and failed test cases by N, wherein N represents the number of accidental correct test cases.
Based on any of the above embodiments, it should be noted that locating a fault statement in a program to be tested by using an Ochiai method includes:
calculating a fault suspected value of each statement by adopting an Ochiai method;
and arranging all sentences in the program to be tested in a descending or ascending order according to the size of the fault suspected value to form a fault sentence sequence, and positioning the fault sentences according to the fault sentence sequence.
It should be noted that, in order to enable a technician to determine the fault statements in the program to be tested as soon as possible, in practical application, all the statements are generally arranged in a descending order according to the size of the fault suspected value.
Based on any of the above embodiments, it should be noted that the method further includes:
when the suspected fault values of a plurality of sentences are the same, determining the suspected fault value weight of each sentence;
correcting the fault suspected value of each statement by using the fault suspected value weight of each statement to obtain a plurality of corrected fault suspected values;
and arranging a plurality of sentences with the same fault suspected value according to the size of the corrected fault suspected value.
Note that, the correction of the failure suspected value by the failure suspected value weight is performed not to change the size of the failure suspected value but to discriminate the size of the failure degree of a plurality of sentences having the same failure suspected value based on the corrected failure suspected value.
In the following, a software fault location device provided by an embodiment of the present invention is introduced, and a software fault location device described below and a software fault location method described above may be referred to each other.
Referring to fig. 3, an embodiment of the present invention provides a software fault locating apparatus, including:
an obtaining module 301, configured to obtain a program to be tested and a test case set, and test the program to be tested by using each test case in the test case set to obtain a statement spectrum and an execution result corresponding to each test case;
a determining module 302, configured to determine, according to the obtained statement spectrum and the execution result, a covered and successful test case, a covered and failed test case, an uncovered and successful test case, and an uncovered and failed test case corresponding to each statement in the program to be tested, respectively;
the calculation module 303 is configured to determine the doubtful degree of each correct test case in the test case set, and calculate the number of accidental correct test cases in the test case set according to the doubtful degrees of all correct test cases;
the positioning module 304 is configured to respectively adjust the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of accidental correct test cases, and position a failure statement in a program to be tested by using an Ochiai method based on an uncovered and successful test case, an uncovered and failed test case, an adjusted covered and successful test case, and an adjusted covered and failed test case corresponding to each statement.
Wherein, the calculation module includes:
the calculation unit is used for calculating the similarity between the statement spectrum of the target correct test case in the test case set and the statement spectrum of each error test case in the test case set by using the Jaccard coefficient aiming at each correct test case to obtain a similarity set;
and the determining unit is used for determining the maximum similarity in the similarity set and taking the maximum similarity as the doubtful degree of the target correct test case.
Wherein, the calculation module is specifically configured to:
and taking the sum of the doubtful degrees of all correct test cases as the number of the accidental correct test cases.
Wherein, the positioning module is specifically configured to:
and reducing the number of covered and successful test cases corresponding to each statement by N, and increasing the number of covered and failed test cases by N, wherein N represents the number of accidental correct test cases.
Wherein, the orientation module includes:
the suspected value of trouble computational element, is used for adopting Ochiai's method to calculate the suspected value of trouble of every statement;
and the positioning unit is used for arranging all the sentences in the program to be tested in a descending or ascending order according to the size of the fault suspected value to form a fault sentence sequence and positioning the fault sentences according to the fault sentence sequence.
Wherein, still include:
the weight calculation module is used for determining the weight of the suspected fault value of each statement when the suspected fault values of the statements are the same;
the suspected value correcting module of the trouble, is used for utilizing the suspected value weight of trouble of every statement to revise the suspected value of trouble of every statement, receive a plurality of corrected suspected values of trouble;
and the arrangement module is used for arranging a plurality of sentences with the same fault suspected value according to the size of the corrected fault suspected value.
Wherein, still include:
and the correction module is used for calculating a correction coefficient corresponding to each statement and correspondingly correcting each statement spectrum by using the correction coefficient corresponding to each execution statement.
It can be seen that, this embodiment provides a software fault locating device, includes: the device comprises a receiving module, a first judging module and a monitoring module. All modules are in work and cooperation and each takes its own role, so that the difference between the suspected fault value and the true fault value of the statement is reduced, the fault judgment accuracy of each statement in the program to be tested is improved, and the software fault positioning efficiency and the working efficiency of technicians are also improved.
In the following, a software fault location device provided by an embodiment of the present invention is introduced, and a software fault location device described below and a software fault location method and apparatus described above may be referred to each other.
Referring to fig. 4, an embodiment of the present invention provides a software fault locating apparatus, including:
a memory 401 for storing a computer program;
a processor 402 for implementing the steps of the software fault localization method according to any of the embodiments described above when executing the computer program.
In the following, a readable storage medium provided by an embodiment of the present invention is introduced, and a readable storage medium described below and a software fault location method, apparatus, and device described above may be referred to each other.
A readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the software fault localization method according to any of the embodiments described above.
In the following, a third software fault location method provided by the embodiment of the present invention is introduced, and the software fault location method described below and any of the embodiments described above may be referred to each other.
Referring to fig. 5, fig. 5 is a schematic diagram of a test case set provided in the present embodiment; referring to fig. 6, fig. 6 is a flowchart of a software fault locating method provided in this embodiment.
1. The dependent variables define:
program to be tested P ═ { E ═ E1,E2,…,EmRepresents it. Wherein E isi(1. ltoreq. i.ltoreq.m) represents the ith program entity, i.e., the statement entity, and m represents the number of program entities constituting the program. T ═ T1,t2,…,tn}: a collection of test cases is represented. Wherein, tiAnd (1 is not less than i and not more than n) represents the ith test case.
Test case ti(1. ltoreq. i. ltoreq. n) sentence Spectrum Ps (t) for executioni)={e1,e2,…,ej,…,emRepresents it. Wherein e isj(1. ltoreq. j. ltoreq.m) represents tiWhether to cover statement EjIf t isiOverlay statement EjThen ej Value 1, otherwise ejThe value is 0.
Pc(ti) Representing test cases ti(1 ≦ i ≦ n) set of covered statements, Pc (t)i) The calculation formula is as follows:
Figure BDA0001815332080000141
Tprepresents a set of successful test cases, i.e., a set of test cases that were successfully executed.
npIndicating the number of successful test cases, i.e. np=|Tp|。
TfAnd representing a failed test case set, namely a set of test cases which fail to execute.
nfIndicating the number of failed test cases, i.e. nf=|Tf|。nuf(s): indicating the number of failed test cases for the uncovered statement s.
ncp(s) represents the number of successful test cases for the overlay statement s, ncp(s) is the interval [0, n ]]Natural numbers in. Let s be EkThen n iscpThe formula for calculation of(s) is:
Figure BDA0001815332080000142
ncf(s) represents the number of failed test cases of the overlay statement s, ncf(s) is the interval [0, n ]]Natural numbers in. Let s be EkThen n iscfThe formula for calculation of(s) is:
Figure BDA0001815332080000143
nup(s) represents the number of successful test cases for the uncovered statement s, nup(s) is the interval [0, n ]]Natural numbers in. Let s be EkThen n isupThe formula for calculation of(s) is:
Figure BDA0001815332080000144
nuf(s) represents the number of failed test cases of the uncovered statement s, nuf(s) is the interval [0, n ]]Natural numbers in. Let s be EkThen n isufThe formula for calculation of(s) is:
Figure BDA0001815332080000145
Ps+(ti)=(c1,c2,…,cj,…,cm): representing a test case ti(1. ltoreq. i. ltoreq.n) sentence spectrum Ps (t)i)={e1,e2,…,ej,…,emAnd (6) generating a corrected statement spectrum after processing.
Pc+(ti) Representing test cases t in a corrected statement spectrumi(1 ≦ i ≦ n) set of covered statements, Pc+(ti) The calculation formula of (2) is as follows:
Figure BDA0001815332080000146
Sim(ti,tj) Representing test cases ti(1. ltoreq. i. ltoreq. n) and tj(j is more than or equal to 1 and less than or equal to n).
Scc(ti) Indicates a successful test case ti(1. ltoreq. i. ltoreq.n) is contingencyAnd correctly testing the doubtful degree of the case. The relationship between the contingency test case and other use cases is shown in detail in fig. 1.
nci(s) represents the number of contingency correct test cases, n, of the cover statement s identified according to the method of the inventionci(s) is the interval [0, n ]]Inner real numbers.
Susp(s) represents the suspicion degree of the statement s, i.e. the suspicion value of the fault, and reflects the suspicion degree of the statement s as the fault statement, and the value range is [0, 1 ].
2. The software fault positioning method provided by the embodiment comprises the following specific implementation steps:
A. generating a statement spectrum aiming at a program to be tested:
for test case tiUsing Ps (t)i)={e1,e2,…,ej,…,emDenotes the test case tiCorresponding statement spectrum, ei(j is not less than 1 and not more than m) is 0 and 1, and represents a test case tiWhether to cover statement Ej. And generating a corresponding statement spectrum for each test case in the test case set T.
B. Processing the statement spectrum to generate a corrected statement spectrum:
to accurately identify contingency correct test cases, test case t is subjected toiCovered statement EjThe following formula is used for Ps (t)i) Correcting to generate Ps+(ti)=(c1,c2,…,cj,…,cm) Please refer to fig. 7 for the spectrum correction procedure.
Figure BDA0001815332080000151
And generating a corresponding modified statement spectrum for each test case in the test case set T.
C. The suspicion of a successful test case being a chance successful test case is measured.
According to the characteristics of the contingency successful test case, whether a successful test case is the contingency successful test case or not cannot be accurately judged.
Pc is calculated by generalized Jaccard coefficient+(ti) And Pc+(tj) As the test case tiAnd tjIs measured by the degree of similarity Sim (t)i,tj) The similarity calculation formula is as follows:
Figure BDA0001815332080000152
for successful test case ti(1≤i≤n),tiSuspicion Scc (t) of successful test cases for chancei) Is tiMaximum of similarity to all failed test cases, suspicion Scc (t)i) The calculation formula is as follows:
Figure BDA0001815332080000161
D. and (4) performing software fault location on the corrected statement spectrum by using an Ochiai software fault location method.
1) Aiming at a statement s, the formula for calculating the statement suspicion degree by using an Ochiai method is as follows:
Figure BDA0001815332080000162
2) with reference to the above process for calculating the degree of doubtful test cases, please refer to fig. 8. Wherein the number of the accidental correct test cases is nci(s) is represented by the formula:
Figure BDA0001815332080000163
3) and (3) removing the accidental correct test cases from the successful and covered test cases, and processing the test cases as failed and covered test cases, namely: n is to beci(s) from ncp(s) removing and converting nci(s) addition to ncfIn(s), the formula for calculating the sentence suspicion degree by using the Ochiai method is modified as follows:
Figure BDA0001815332080000164
4) the suspicious values of all the sentences are corrected according to the modified Ochiai+And(s) after the calculation is finished, sequencing the sentences according to the size of the suspicious values to obtain a software fault positioning report.
Determining the weight of a suspected fault value of each statement for the statements with the same suspected fault values; correcting the fault suspicion value (namely the suspicion degree) of each statement by using the fault suspicion value weight of each statement to obtain a plurality of corrected fault suspicion values; and arranging a plurality of sentences with the same fault suspected value according to the size of the corrected fault suspected value.
Wherein, the weight calculation formula is as follows:
Figure BDA0001815332080000165
and taking the product of the calculated weight and the suspicion degree as a corrected fault suspicion value.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (8)

1. A software fault locating method is characterized by comprising the following steps:
acquiring a program to be tested and a test case set, testing the program to be tested by using each test case in the test case set, and acquiring a statement spectrum and an execution result corresponding to each test case;
respectively determining a covered and successful test case, a covered and failed test case, an uncovered and successful test case and an uncovered and failed test case corresponding to each statement in the program to be tested according to the obtained statement spectrum and the execution result;
determining the doubtful degree of each correct test case in the test case set, and calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases;
respectively adjusting the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of the accidental correct test cases, and positioning a fault statement in the program to be tested by adopting an Ochiai method based on the uncovered and successful test cases, the uncovered and failed test cases, the adjusted covered and successful test cases and the adjusted covered and failed test cases corresponding to each statement;
wherein the determining the doubtful degree of each correct test case in the test case set comprises:
for each correct test case, the following steps are respectively adopted to determine the doubtful degree:
calculating the similarity between the statement spectrum of the target correct test case in the test case set and the statement spectrum of each wrong test case in the test case set by using the Jaccard coefficient to obtain a similarity set;
determining the maximum similarity in the similarity set, and taking the maximum similarity as the doubtful degree of the target correct test case;
wherein, the calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases comprises:
and taking the sum of the doubtful degrees of all correct test cases as the number of the accidental correct test cases.
2. The method according to claim 1, wherein the adjusting the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of the contingency correct test cases comprises:
and reducing the number of covered and successful test cases corresponding to each statement by N, and increasing the number of covered and failed test cases by N, wherein N represents the number of the accidental correct test cases.
3. The software fault locating method according to claim 2, wherein locating the fault statement in the program to be tested by using an Ochiai method comprises:
calculating a fault suspected value of each statement by adopting an Ochiai method;
and arranging all sentences in the program to be tested in a descending or ascending order according to the size of the fault suspected value to form a fault sentence sequence, and positioning the fault sentences according to the fault sentence sequence.
4. The software fault locating method of claim 1, further comprising:
when the suspected fault values of a plurality of sentences are the same, determining the suspected fault value weight of each sentence;
correcting the fault suspected value of each statement by using the fault suspected value weight of each statement to obtain a plurality of corrected fault suspected values;
and arranging a plurality of sentences with the same fault suspected value according to the size of the corrected fault suspected value.
5. The method according to any one of claims 1 to 4, wherein before determining the plausibility of each correct test case in the set of test cases, the method further comprises:
and calculating a correction coefficient corresponding to each statement, and correspondingly correcting each statement spectrum by using the correction coefficient corresponding to each execution statement.
6. A software fault locating device, comprising:
the system comprises an acquisition module, a test case collection module and a test execution module, wherein the acquisition module is used for acquiring a program to be tested and the test case collection, testing the program to be tested by using each test case in the test case collection and acquiring a statement spectrum and an execution result corresponding to each test case;
the determining module is used for respectively determining a covered and successful test case, a covered and failed test case, an uncovered and successful test case and an uncovered and failed test case corresponding to each statement in the program to be tested according to the obtained statement spectrum and the execution result;
the calculation module is used for determining the doubtful degree of each correct test case in the test case set and calculating the number of accidental correct test cases in the test case set according to the doubtful degree of all correct test cases;
the positioning module is used for respectively adjusting the number of covered and successful test cases and the number of covered and failed test cases corresponding to each statement according to the number of the accidental correct test cases, and positioning the fault statement in the program to be tested by adopting an Ochiai method based on the uncovered and successful test cases, the uncovered and failed test cases, the adjusted covered and successful test cases and the adjusted covered and failed test cases corresponding to each statement;
wherein, the calculation module includes:
the calculation unit is used for determining the doubtful degree by respectively adopting the following steps aiming at each correct test case: calculating the similarity between the statement spectrum of the target correct test case in the test case set and the statement spectrum of each wrong test case in the test case set by using the Jaccard coefficient to obtain a similarity set;
the determining unit is used for determining the maximum similarity in the similarity set and taking the maximum similarity as the doubtful degree of the target correct test case;
wherein, the calculation module is specifically configured to: and taking the sum of the doubtful degrees of all correct test cases as the number of the accidental correct test cases.
7. A software fault locating device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the software fault localization method of any one of claims 1-5 when executing the computer program.
8. A readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the software fault localization method according to any one of claims 1-5.
CN201811144869.8A 2018-09-28 2018-09-28 Software fault positioning method, device, equipment and readable storage medium Active CN109254924B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811144869.8A CN109254924B (en) 2018-09-28 2018-09-28 Software fault positioning method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811144869.8A CN109254924B (en) 2018-09-28 2018-09-28 Software fault positioning method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN109254924A CN109254924A (en) 2019-01-22
CN109254924B true CN109254924B (en) 2022-02-08

Family

ID=65048461

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811144869.8A Active CN109254924B (en) 2018-09-28 2018-09-28 Software fault positioning method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN109254924B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110209573B (en) * 2019-05-08 2023-06-02 三峡大学 Method for enhancing software fault positioning effect
CN110362484B (en) * 2019-07-03 2022-03-01 北京航空航天大学 Method and device for positioning multiple faults of software, electronic equipment and storage medium
CN110688310A (en) * 2019-09-20 2020-01-14 中国人民解放军63921部队 Software test case distance calculation method based on attraction
CN115185814A (en) * 2022-06-13 2022-10-14 中南大学 Multi-defect positioning method, system and equipment based on two-dimensional program frequency spectrum

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102193864A (en) * 2011-05-13 2011-09-21 南京大学 Test case set optimization method of coverage-based error positioning technology
CN102915271A (en) * 2012-10-31 2013-02-06 北京邮电大学 Method for optimizing unit regression test case set based on control flow diagram
CN106909502A (en) * 2017-01-13 2017-06-30 河南工业大学 Accidental correctness test case recognition methods and software error localization method
CN107992426A (en) * 2017-12-26 2018-05-04 河南工业大学 A kind of software error localization method excavated based on Frequent tree mining and processing unit
CN108415848A (en) * 2018-05-14 2018-08-17 河南工业大学 A kind of software error localization method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102193864A (en) * 2011-05-13 2011-09-21 南京大学 Test case set optimization method of coverage-based error positioning technology
CN102915271A (en) * 2012-10-31 2013-02-06 北京邮电大学 Method for optimizing unit regression test case set based on control flow diagram
CN106909502A (en) * 2017-01-13 2017-06-30 河南工业大学 Accidental correctness test case recognition methods and software error localization method
CN107992426A (en) * 2017-12-26 2018-05-04 河南工业大学 A kind of software error localization method excavated based on Frequent tree mining and processing unit
CN108415848A (en) * 2018-05-14 2018-08-17 河南工业大学 A kind of software error localization method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于偶然正确测试用例识别的错误定位方法;李登辉;《中国优秀硕士学位论文全文数据库信息科技辑》;20160315(第03期);正文第1章第1.2.1节第4段,第2章第1段至第6章最后一段 *

Also Published As

Publication number Publication date
CN109254924A (en) 2019-01-22

Similar Documents

Publication Publication Date Title
CN109254924B (en) Software fault positioning method, device, equipment and readable storage medium
CN109447263B (en) Space abnormal event detection method based on generation of countermeasure network
US9459947B2 (en) Error report processing using call stack similarity
AU2018214120B2 (en) System and method for determining an optimum QC strategy for immediate release results
CN103995780B (en) A kind of program error localization method based on sentence frequency statistics
CN109188502B (en) Beam position monitor abnormity detection method and device based on self-encoder
CN115800272B (en) Power grid fault analysis method, system, terminal and medium based on topology identification
CN110515826A (en) A kind of software defect positioning method based on number frequency spectrum and neural network algorithm
Miao et al. A clustering-based strategy to identify coincidental correctness in fault localization
US6292738B1 (en) Method for adaptive detection of engine misfire
Park et al. Transient diagnosis and prognosis for secondary system in nuclear power plants
CN112231134A (en) Fault processing method and device of neural network processor, equipment and storage medium
CN103019943B (en) Software error positioning method catering to rare case of failed test cases
US20050102566A1 (en) Method for diagnosing complex system faults
CN115617564A (en) Processing method and device for kernel exception, electronic equipment and storage medium
US20210318879A1 (en) Instruction execution method, device, and electronic equipment
CN115640155A (en) Program automatic repairing method and system based on statement dependence and patch similarity
Zhou et al. A fault-localization approach based on the coincidental correctness probability
CN106547690A (en) Based on the Software Reliability Modeling method and device under new fitting criterion
KR102621393B1 (en) Apparatus for diagnosing transformer
CN116304776B (en) Power grid data value anomaly detection method and system based on k-Means algorithm
CN109255306B (en) Method, device and equipment for testing face detector and storage medium
CN111953544B (en) Fault detection method, device, equipment and storage medium of server
CN112948253B (en) Test case generation method based on VRM model
CN117540378A (en) Training method, device and equipment for detection result judgment model

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