Tests de mutabilité

A.K.A. Mutation testing

C’est quoi un mutant?

Pas ça

Un mutant c'est...

  • Version modifiée du code original
  • Plusieurs mutants peuvent être crées dans la même ligne
  • Et ils doivent...

MOURIR

C’est quoi des tests de mutabilité?

Exemple #1

def light?(switch)
  switch ? :on : :off
end 

Original

def light?(switch)
  true ? :on : :off
end 

Mutant

Test

expect(light?(true)).to be(:on) 

Les tests passent encore...

def light?(switch)
  switch ? :on : :off
end 

Original

def light?(switch)
  true ? :on : :off
end 

Mutant

Test

expect(light?(true)).to be(:on)
expect(light?(false)).to be(:off)

Le mutant est mort

Mutation testing pour tous

Ruby

Mutant - https://github.com/mbj/mutant

Python

MutPy - https://pypi.python.org/pypi/MutPy/0.4.0

Java

PIT - http://pitest.org/

PHP

Mutagenesis - https://github.com/padraic/mutagenesis

DEMO

Tests de mutabilité

By Jean-François Chaput