Sunteți pe pagina 1din 10

What

is Muta6on Tes6ng?
Muta&on Tes&ng is a tes6ng technique
that focuses on measuring the adequacy of
test cases.
Muta&on Tes&ng is NOT a tes6ng strategy
like path or data-ow tes6ng. It does not
outline test data selec6on criteria.
Muta&on Tes&ng should be used in
conjunc6on with tradi6onal tes6ng
techniques, not instead of them.
Dependable So,ware Systems
(Muta6on)

Muta6on Tes6ng
Faults are introduced into the program by
crea6ng many versions of the program
called mutants.
Each mutant contains a single fault.
Test cases are applied to the original
program and to the mutant program.
The goal is to cause the mutant program to
fail, thus demonstra6ng the eec6veness
of the test case.
Dependable So,ware Systems
(Muta6on)

Test Case Adequacy


A test case is adequate if it is useful in
detec6ng faults in a program.
A test case can be shown to be adequate by
nding at least one mutant program that
generates a dierent output than does the
original program for that test case.
If the original program and all mutant
programs generate the same output, the test
case is inadequate.
Dependable So,ware Systems
(Muta6on)

Mutant Programs
Muta6on tes6ng involves the crea6on of a set
of mutant programs of the program being
tested.
Each mutant diers from the original program
by one muta.on.
A muta.on is a single syntac6c change that is
made to a program statement.

Dependable So,ware Systems


(Muta6on)

Example of a Program Muta6on


1 int max(int x, int y)
2 {
3 int mx = x;
4 if (x > y)
5 mx = x;
6 else
7 mx = y;
8 return mx;
9 }

Dependable So,ware Systems


(Muta6on)

1 int max(int x, int y)


2 {
3 int mx = x;

4 if (x < y)
5 mx = x;
6 else
7 mx = y;
8 return mx;
9 }

Categories of Muta6on Operators


Operand Replacement Operators:
Replace a single operand with another
operand or constant. E.g.,
if (5 > y)
if (x > 5)
if (y > x)

Replacing x by constant 5.
Replacing y by constant 5.
Replacing x and y with each other.

E.g., if all operators are {+,-,*,**,/} then the


following expression a = b * (c - d) will
generate 8 mutants:
4 by replacing *
4 by replacing -.

Dependable So,ware Systems


(Muta6on)

Categories of Muta6on Operators


Expression Modica6on Operators:
Replace an operator or insert new operators. E.g.,
if (x == y)
if (x >= y)
if (x == ++y)

Dependable So,ware Systems


(Muta6on)

Replacing == by >=.
Inser6ng ++.

Categories of Muta6on Operators


Statement Modica6on Operators:
E.g.,
Delete the else part of the if-else statement.
Delete the en6re if-else statement.
Replace line 3 by a return statement.

Dependable So,ware Systems


(Muta6on)

Muta6on operators
Performed by jester mothra n other tools

S-ar putea să vă placă și