Transcript
Page 1: A Theoretical Framework for Understanding Mutation-Based Testing Methods

A Theoretical Framework for Understanding Mutation-Based Testing Methods

Donghwan Shin and Doo-Hwan Bae

KAIST, South Korea

@ ICST 2016

Page 2: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Mutation-based testing has been widely studied for addressing various testing problems

Test set selection Fault localization Program repair

2

π‘π‘œ π‘šπ‘§

π‘šπ‘₯

π‘šπ‘¦

Artificially mutated program𝒑𝒐: an original programπ’Ž: a mutant generated from 𝒑𝒐

Artificial fault Partial fix

Systematically generate π’Ž from 𝒑𝒐

and use the differences between them

difference difference

difference

Page 3: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

There is a solid theoretical framework for general testing process – β€œtesting system”

Such theoretical framework facilitates a clear understanding of the essence of complex problems

3

𝑷 attempts to implement 𝑺

𝑻 is designed to consider 𝑺 and 𝑷

𝑢 determines the correctness of 𝑷 for 𝑻

β‹―

𝑃𝑆

𝑇𝑂

𝑷 is a set of programs 𝑺 is a set of specifications 𝑻 is a set of tests 𝑢 is a set of oracles

Fundamental testing factors and their relationships[1][2]

[1] J. S. Gourlay, β€œA mathematical framework for the investigation of testing,” Software Engineering, IEEE Transactions on, no. 6, pp. 686-709, 1983.[2] M. Staats, M. W. Whalen, and M. P. E. Heimdahl, β€œPrograms, tests, and oracles: the foundations of testing revisited,” in Proceedings of ICSE 2011, pp. 391-400.

Page 4: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Surprisingly little attention has been paid to the theoretical framework of mutation-based testing

4

Even the testing system is not adequate to mutation-based testing because it focuses on the correctness.

𝑷 attempts to implement 𝑺

𝑻 is designed to consider 𝑺 and 𝑷

𝑢 determines the correctness of 𝑷 for 𝑻

β‹―

𝑃𝑆

𝑇𝑂

𝑺 is a set of specifications 𝑷 is a set of programs 𝑻 is a set of tests 𝑢 is a set of oracles

How to formally describethe behavioral differences between programs and its mutants in testing?

𝑀

Page 5: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Key idea: a new testing factor for difference

5

π‘œ 𝑑, 𝑝 = 1 π‘‘π‘Ÿπ‘’π‘’ ,0 π‘“π‘Žπ‘™π‘ π‘’ ,

if 𝒑 is correct for 𝒕

otherwise

In the testing system, an oracle 𝒐 implies the correctness of a program 𝒑 for a test 𝒕 as follows:

Let us define a new testing factor 𝑿to imply the difference between two programs for a test

𝑋(𝑑, 𝑝π‘₯, 𝑝𝑦)

Page 6: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

A theoretical framework for the difference in mutation-based testing

6

In this talk:β€’ Define and extend a new testing factor to formalize the

β€œdifference-based testing framework”

What you can do using this framework:β€’ Formally describe the behavioral differences of programs

given a set of tests.

β€’ Quantitatively represent and analyze the behavioral differences in a multi-dimensional space.

β€’ Guide to understand mutation-based testing methods.

Page 7: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Outline

Test differentiator

β€’ A new testing factor for the notion of difference

d-vectorβ€’ Extended differentiator for a set of tests

Positionβ€’ Redefined d-vector in a multi-dimensional space

Position deviance relation

β€’ Formal relation between positions

Position Deviance Latticeβ€’ Graphical model for positions and its deviance relation

Applications

7

Page 8: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Outline

Test differentiator

β€’ A new testing factor for the notion of difference

d-vectorβ€’ Extended differentiator for a set of tests

Positionβ€’ Redefined d-vector in a multi-dimensional space

Position deviance relation

β€’ Formal relation between positions

Position Deviance Latticeβ€’ Graphical model for positions and its deviance relation

Applications

8

Page 9: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Test differentiator: a new testing factor (1/2)

9

Def. 1: A test differentiator 𝑑 is a function such that

𝑑 𝑑, 𝑝π‘₯, 𝑝𝑦 = 1 π‘‘π‘Ÿπ‘’π‘’ ,0 π‘“π‘Žπ‘™π‘ π‘’ ,

if the behaviors of 𝒑𝒙 and π’‘π’š are different for 𝒕

otherwise

𝑑 𝑑, π‘π‘œ, π‘š = 1 β€œπ‘‘ detects the difference between 𝒑𝒐 and π’Žβ€

Example

β€œThe test kills the mutant”

Page 10: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Test differentiator: a new testing factor (2/2)

It clarifies tricky concepts in mutation-based testing.

10

A test 𝑑 detects a fault in π‘π‘œ 𝑑 𝑑, 𝑝𝑠, π‘π‘œ = 1

A test 𝑑 kills a mutant π‘š 𝑑 𝑑, π‘π‘œ, π‘š = 1

𝑝𝑠: the projection of the specification (i.e., true requirements of π‘π‘œ)

It shows how 𝑑 is important in mutation-based testing.

𝑑 observes internal values

𝑑 observes only output

Weak mutation Strong mutation

Page 11: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Outline

Test differentiator

β€’ A new testing factor for the notion of difference

d-vectorβ€’ Extended differentiator for a set of tests

Positionβ€’ Redefined d-vector in a multi-dimensional space

Position deviance relation

β€’ Formal relation between positions

Position Deviance Latticeβ€’ Graphical model for positions and its deviance relation

Applications

11

Page 12: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

𝐝-vector: extended 𝑑 as a vector form

12

Def. 2: A 𝑑-vector 𝒅 is an 𝒏-dimensional vector, such that

𝐝 𝐭, 𝑝π‘₯, 𝑝𝑦 = 𝑑 𝑑1, 𝑝π‘₯, 𝑝𝑦 , … , 𝑑(𝑑𝑛, 𝑝π‘₯, 𝑝𝑦)

for a collection of tests 𝐭 = 𝑑1, 𝑑2, β‹― , 𝑑𝑛 ∈ 𝑻𝒏.

Test Behavior 𝐝-vector = behavioral difference

𝐭 𝑝𝑠 π‘π‘œ π‘š 𝐝 𝐭, 𝑝𝑠, π‘π‘œ 𝐝 𝐭, 𝑝𝑠, π‘š 𝐝 𝐭, π‘π‘œ, π‘š

𝑑1 A A A

0,1,1,1 0,1,1,0 0,0,1,1𝑑2 B A A

𝑑3 C A D

𝑑4 D A D

𝑑-vector concisely describes the behavioral differences of programs for a set of tests

Example

Page 13: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

𝐝-vector = position in a multi-dimensional space

13

x

z

y

p(1,1,2)

A vector represents a point in a multi-dimensional space.

The position of a point is relative to the origin.

𝐝 𝐭, 𝑝π‘₯, 𝑝𝑦= 𝑑1, … , 𝑑𝑛

We can think of a d-vector as the representation of a position in a space.

Page 14: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Position and its space from a 𝐝-vector

14

Def. 3: The position of a program 𝒑𝒙 relative to another program 𝒑𝒓 in a multi-dimensional space corresponding to a set of tests 𝐭 is

𝐝 𝐭, π‘π‘Ÿ , 𝑝π‘₯ = ππ‘π‘Ÿπ­ 𝑝π‘₯ .

The space is induced by 𝐭, π‘π‘Ÿ , 𝑑 .

𝐭 = π’•πŸ, β‹― , 𝒕𝒏 corresponds to the 𝒏-dimensions.

π‘π‘Ÿ corresponds to the origin of the space.

𝑑 corresponds to the notion of difference in the space.

A position of 𝒑𝒙 relative to the origin 𝒑𝒓 implies the behavioral difference between 𝒑𝒙 and 𝒑𝒓 for a set of tests 𝐭.

Page 15: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Outline

Test differentiator

β€’ A new testing factor for the notion of difference

d-vectorβ€’ Extended differentiator for a set of tests

Positionβ€’ Redefined d-vector in a multi-dimensional space

Position deviance relation

β€’ Formal relation between positions

Position Deviance Latticeβ€’ Graphical model for positions and its deviance relation

Applications

15

Page 16: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Position deviance relation (1/3)

Add more tests increasing dimensions make positions deviant from its origin

16

𝐭 = {β‹― , 𝑑𝑖 , 𝑑𝑖+1, β‹― }

𝐩𝐱 = β‹― , 0,0,β‹―

𝐩𝐲 = β‹― , 0,1,β‹―

𝐭 = {β‹― , 𝑑𝑖 , β‹― }

𝐩𝐱 = β‹― , 0,β‹―

𝐩𝐲 is deviant from 𝐩𝐱 by 𝑑𝑖+1

Example

Page 17: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Position deviance relation (2/3)

Forms a partial order based on transitivity.

17

𝐩𝟏 = β‹― , 0,0,β‹―

𝐩𝟐 = β‹― , 0,1,β‹―

π©πŸ‘ = β‹― , 1,1,β‹―

π©πŸ’ = β‹― , 1,0,β‹―

π©πŸ‘ is more deviant than 𝐩𝟏.

π©πŸ‘ and π©πŸ’ are incomparable.

Page 18: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Position deviance relation (3/3)

If π‘π‘Ÿ = π‘π‘œ, the deviance relation on positions impliesthe dynamic subsumption* on mutants at the positions.

18

* Ammann, Paul, Marcio E. Delamaro, and Jeff Offutt. ”Establishing theoretical minimal sets of mutants.” ICST 2014.

Dynamic subsumptionIf π‘šπ‘₯ is killed, then π‘šπ‘¦ must be killed.

𝐩𝐱 = β‹― , 0,0,β‹― = {π‘šπ‘₯}

𝐩𝐲 = β‹― , 0,1,β‹― = {π‘šπ‘¦}

𝐩𝐨 = 0,β‹― , 0 = {π‘π‘œ}

Page 19: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Outline

Test differentiator

β€’ A new testing factor for the notion of difference

d-vectorβ€’ Extended differentiator for a set of tests

Positionβ€’ Redefined d-vector in a multi-dimensional space

Position deviance relation

β€’ Formal relation between positions

Position Deviance Latticeβ€’ Graphical model for positions and its deviance relation

Applications

19

Page 20: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Position Deviance Lattice (PDL) (1/4)

20

It shows the positions with their deviance relation.β€’ Each dimension (=test) has only two positions, 0 or 1.

β€’ The number of positions in a 𝑛-dimensional space = 2𝑛.

𝐩0 = 0,0,0

𝐩2 = 0,1,0

𝐩5 = 1,0,1

𝐩7 = 1,1,1

𝐩1 = 1,0,0 𝐩3 = 0,0,1

𝐩4 = 1,1,0 𝐩6 = 0,1,1

𝑑1 𝑑2𝑑3

𝑑1 𝑑2 𝑑3

Dimensions

3-dimensional PDL

Example

Page 21: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Position Deviance Lattice (PDL) (2/4)

21

It growths as more tests added.

𝐩0

𝐩2

𝐩5

𝐩7

𝐩1 𝐩3

𝐩4 𝐩6

𝑑1 𝑑2𝑑3

𝑑1 𝑑2 𝑑3

Dimensions

Example

𝐩𝟎, π©πŸ‘

𝐩𝟐, π©πŸ”π©πŸ, π©πŸ“

π©πŸ’, π©πŸ•

𝑑1 𝑑2

𝐩𝟎, 𝐩𝟐, π©πŸ‘, π©πŸ”

𝐩𝟏, π©πŸ’, π©πŸ“, π©πŸ•

𝑑1

𝐭 = {𝑑1, 𝑑2} 𝐭 = {𝑑1, 𝑑2, 𝑑3}

𝐭 = {𝑑1}

Page 22: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Outline

Test differentiator

β€’ A new testing factor for the notion of difference

d-vectorβ€’ Extended differentiator for a set of tests

Positionβ€’ Redefined d-vector in a multi-dimensional space

Position deviance relation

β€’ Formal relation between positions

Position Deviance Latticeβ€’ Graphical model for positions and its deviance relation

Applications

22

Page 23: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Minimal set of mutants in PDL (1/2)

In PDL where 𝒑𝒓 = 𝒑𝒐, mutants in β€œthe least deviant” positions form the minimal set of mutants.

23

𝐩0 = {π‘π‘œ}

𝐩2 = {}

𝐩5 = {π‘š3}

𝐩7 = {π‘š4}

𝐩1 = {π‘š1} 𝐩3 = {}

𝐩4 = {} 𝐩6 = {π‘š2}

𝑑1 𝑑2𝑑3

Page 24: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Minimal set of mutants in PDL (2/2)

What is the maximum bound of the minimal set of mutants for 𝑛 tests?β€’ Key: if two mutants are at two comparable positions, then

one must be dynamically subsumed by another.

β€’ Sperner's theorem says that the maximum number of incomparable nodes in an 𝑛-dim lattice is given as follows:

24

max(|π‘€π‘šπ‘–π‘›π‘–π‘šπ‘Žπ‘™|) =𝑛

𝑛/2

(E.g.) If we have 10 tests, # of minimal mutants ≀ πŸπŸŽπŸ“

= 252

Page 25: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Not-killed area

Killed area

Understanding and extending the mutation adequacy criterion using PDL

25

𝒅(𝒕𝒋, 𝒑𝒐,π’Žπ’Š) π’ŽπŸ π’ŽπŸ π’ŽπŸ‘ π’ŽπŸ’

π’•πŸ 1 1 0 0

π’•πŸ 0 0 1 1

π‘π‘œ, π‘š1, π‘š2, π‘š3, π‘š4𝑇𝑆 = {}

Page 26: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Not-killed area

Killed area

Understanding and extending the mutation adequacy criterion using PDL

26

π‘π‘œ, π‘š3, π‘š4

π‘š1, π‘š2

𝑑1

𝑇𝑆 = {𝑑1}

𝒅(𝒕𝒋, 𝒑𝒐,π’Žπ’Š) π’ŽπŸ π’ŽπŸ π’ŽπŸ‘ π’ŽπŸ’

π’•πŸ 1 1 0 0

π’•πŸ 0 0 1 1

Page 27: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Not-killed area

Killed area

Understanding and extending the mutation adequacy criterion using PDL

27

π‘π‘œ

π‘š3, π‘š4π‘š1, π‘š2

𝑑1 𝑑2

(empty)

𝑇𝑆 = {𝑑1, 𝑑2}

𝒅(𝒕𝒋, 𝒑𝒐,π’Žπ’Š) π’ŽπŸ π’ŽπŸ π’ŽπŸ‘ π’ŽπŸ’

π’•πŸ 1 1 0 0

π’•πŸ 0 0 1 1

Page 28: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Not-killed area

Killed area

Understanding and extending the mutation adequacy criterion using PDL

28

π‘π‘œ

π‘š3, π‘š4π‘š1, π‘š2

𝑑1 𝑑2

(empty)

𝑇𝑆 = {𝑑1, 𝑑2}

Traditional mutation adequacy criterionβ€’ A test suite that distinguishes the positions of mutants from

the position of 𝒑𝒐will likely detect real faults.

Page 29: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Not-killed area

Killed area

Understanding and extending the mutation adequacy criterion using PDL

29

π‘π‘œ

π‘š3, π‘š4π‘š1, π‘š2

𝑑1 𝑑2

(empty)

𝑇𝑆 = {𝑑1, 𝑑2}

Claim for the existing mutation adequacy criterionβ€’ In the β€œkilled area”, there are still several mutants which are

not distinguished in terms of their positions.

Page 30: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Not-killed area

Killed area

Understanding and extending the mutation adequacy criterion using PDL

30

π‘π‘œ

π‘š4

π‘š1

(empty)

π‘š2 (empty)

(empty) π‘š3

𝑑1 𝑑2𝑑3

Distinguishing more mutants increases fault detection*β€’ A test suite that distinguishes the positions of mutants from

each other will likely detect real faults.

* Donghwan Shin, Shin Yoo, and Doo-Hwan Bae. β€œDiversity-aware mutation adequacy criterion for improving fault detection capability.” Mutation 2016

Page 31: A Theoretical Framework for Understanding Mutation-Based Testing Methods

Β© Donghwan Shin, 2016

Conclusion

Correctness-based think difference-based thinkβ€’ Incorrect programs seem useless, while different programs

seems meaningful.

PDL may guide you to consider difference-based think.

31

𝑑1 𝑑2 𝑑3

Dimensions


Top Related