Final 12 (69 To 74)
Final 12 (69 To 74)
Final 12 (69 To 74)
Lecture No. 11
Module 69:
Confidence based testing techniques
Confidence based testing techniques
Structural (coverage-
based) techniques:
Goodness was determined by
the coverage of the product
by the test set so far: e.g., %
of statements or
requirements tested
Often based on control-flow
graph of the program
Three techniques:
– control-flow coverage
– data-flow coverage
– coverage-based testing of
requirements
Confidence based techniques
Confidence based
methods:
In coverage-based testing,
we take the structure of
the artifact to be tested
into account
In fault-based testing, we
do not directly consider
this artifact
We look for a test set with
high ability to detect faults
Two techniques:
Fault seeding
Mutation testing
Confidence based techniques
Fault seeding and mutation
testing are fault-oriented
techniques, applicable to all
levels of testing.
In Fault Seeding Technique,
a predefined number of
artificially generated errors
is "sown" in the program
code.
Confidence based techniques
Whereas, in mutation
testing, we sow one fault at
a time leading to original
program and mutant version
of that program
Test runs are used to detect
these faults
We examine ratio between
actual and artificial errors
based on the total number
of detected errors.
The testers do not know the
artificially generated errors.
Module 70:
Mutation Testing
Mutation Testing
Mutation Testing is a
testing technique that
focuses on measuring the
adequacy of test cases.
Mutation Testing is NOT a
testing strategy like path or
data-flow testing. It does
not outline test data
selection criteria.
Mutation Testing should
be used in conjunction with
traditional testing
techniques, not instead of
them.
Mutation Testing
Assumptions underlying
mutation testing:
Competent Programmer
Hypothesis: competent
programmers write
programs that are
approximately correct
Mutant programs:
Mutation testing involves
the creation of a set of
mutant programs of the
program being tested.
Each mutant differs from
the original program by one
mutation.
A mutation is a single
syntactic change that is
made to a program
statement.
Test and Mutation Adequacy
Mutation adequacy:
Mutation adequacy uses a similar concept to fault seeding to
evaluate the effectiveness of a test suite.
Assume we have a test suite TS with confidence C with total
test cases c(j).
Assume that the program under test P passes all the test
cases c(j) for 1 <= j <= C.
Can we stop testing? That is, have we tested P adequately?
The mutation adequacy criterion provides one answer that we
might use.
The mutation adequacy approach differs from fault seeding in
that it is applied at a particular point in the testing process
and also in that faults are not directly inserted into P.
Test and Mutation Adequacy
Mutation adequacy:
Instead, a series of mutants m(i) are created.
Each mutant m(i) differs from P by the injection of exactly one
fault.
Let M be the total number of mutants m(i).
The test suite TS is applied to each mutant m(i).
If a particular mutant m(i) fails any test in c(j), then it is said
to be killed.
All mutants that are not killed are said to remain live at this
point.
The ratio of killed to total mutants (K/M) can be considered a
measure of adequacy of TS.
Test and Mutation Adequacy
Mutation score:mutation
score for a set of test cases
is the percentage of non-
equivalent mutants killed by
the test data.
Mutation Score = 100 * D
/ (N - E)
D = Dead mutants
N = Number of mutants
E = Number of
equivalent mutants
A set of test cases is
mutation adequate if its
mutation score is 100%.
Test and Mutation Adequacy
Mutation testing –
evaluation:
Theoretical and
experimental results have
shown that mutation testing
is an effective approach to
measuring the adequacy of
test cases.
The major drawback of
mutation testing is the cost
of generating the mutants
and executing each test
case against them.
Module 72:
Fault Seeding
Fault Seeding
Question:
Seed 100 faults into a project at time 0.
Testing continues to time 30, at which point 73 of the seeded
faults have been detected.
If 219 actual faults were discovered, what is the expected
number of total faults prior to seeding?
How many latent faults are expected to remain in the software
at time 30?
Answers:
The discovered original faults are three times the numbered of
discovered seeded faults, so 300 original faults are expected.
The latent faults are those remaining and not removed: (300 -
219) original faults plus (100 - 73) seeded faults, that is 81 +
27 = 108 latent faults.
Fault Seeding
Fault types:
Domain faults
Computational faults
…
Fault Seeding
Fault Seeding Mutation Testing
v
Fault Seeding
Mutation Testing
Best suitable for smaller
systems
Critical systems
Fault localization is easy
Fault Seeding
Economical yet fault
localization is difficult
Module 73:
Mutation Testing Example
Mutation Testing Example
Example Code:
We do two mutations
One by one
Therefore there are three
versions, two mutants and one
original code
Three versions:
Two versions: