Paweł Sawicz
Twitter : @sawiczpawel LinkedIn :http://tiny.cc/7zvjqw
@sawiczpawel
http://pawel.sawicz.eu
Dev @ Zopa
What is mutation testing ?
Why you should care about this ?
Where it's useful ?
"In biology, a mutation is a permanent change of the nucleotide sequence of the genome of an organism, virus, or extrachromosomal DNA or other genetic elements" - via wikipedia.com
In technology, a mutation is a permanent change of an instruction in a function of a program.
1971 - Richard Lipton
1980 - Timothy Budd
public int CalculateCO2Emmision(int engineSize)
{
if (engineSize < 4)
{
return 200;
}
else
{
return 400;
}
}
[Test]
public void CalculateCO2Emmision_EngineSize3_Return200()
{
//arrange
var checker = new SimpleIf();
//act
var result = checker.CalculateCO2Emmision(3);
//assert
Assert.AreEqual(200, result);
}
public int CalculateCO2Emmision(int engineSize)
{
if (engineSize <= 4)
{
return 200;
}
else
{
return 400;
}
}
public void CalculateCO2Emmision_EngineSize3_Return200()
{
//arrange
var checker = new SimpleIf();
//act
var result = checker.CalculateCO2Emmision(3);
//assert
Assert.AreEqual(200, result);
}
[Test]
[TestCase(3, 200)]
[TestCase(4, 400)]
[TestCase(5, 400)]
public void CalculateCO2Emmision_EngineSize3_Return200_BestOne(int engineSize, int expectedC02)
{
//arrange
var checker = new SimpleIf();
//act
var result = checker.CalculateCO2Emmision(engineSize);
//assert
Assert.AreEqual(expectedC02, result);
}
public int CalculateCO2Emmision(int engineSize)
{
if (engineSize <= 4)
{
return 200;
}
else
{
return 400;
}
}
Mutants
public int CalculateCO2Emmision(int engineSize)
{
if (engineSize < 4)
{
return 200;
}
else
{
return 400;
}
}
Mutant runner + ILSpy demo
In technology, a mutation is a permanent change of the instruction of the function of a program.
Traditional code coverage tools measure test coverage of the code, not business intent
Mutation runner + ILSpy
Mutation runner + ILSpy
.NET :
Ruby :
@sawiczpawel, pawel@sawicz.eu
Feedback @ https://confocal.io/
code :pawel
By Paweł Sawicz