- junit official site
- org.pitest official site
- mvn compile
- mvn test
- mvn org.pitest:pitest-maven:mutationCoverage
You will find report at {project dir}\target\pit-reports
Mutation test is a way to test your unit test and production code is good enough or not.
examples and description below can find in ref link.
- Conditionals Boundary Mutator
mutate operators
<, <=, >, >=
ex:
if (a > b) {
System.out.println("a is bigger than b");
}
will be mutate to
if (a >= b) {
System.out.println("a is bigger than b");
}
- Increments Mutor
only mutate local veriables
public int Increment(int i) {
i++;
return i;
}
will be mutate to
public int Increment(int i) {
i--;
return i;
}
- Invert Negatives Mutor
inverts negation of integer and floating point numbers
public float negate(final float i) {
return -i;
}
will be mutate to
public float negate(final float i) {
return i;
}
- Math Mutor
replaces binary arithmetic operations for either integer or floating-point arithmetic with another operation
double num3 = num1 + num2;
will be mutate to
double num3 = num1 - num2;
- Negate Conditionals Mutor
mutate conditionals
if (a == b) {
System.out.println("a is equal to b");
}
will be mutate to
if (a != b) {
System.out.println("a is equal to b");
}
- Return Values Mutator
mutates the return values of method calls
different from return type, if value type then change to default or opposite value, if reference type then return null, if return null then throw java.lang.RuntimeException
public Object foo() {
return new Object();
}
will be mutate to
public Object foo() {
new Object();
return null;
}
- Void Method Calls
removes method calls to void methods
public void someVoidMethod(int i) {
System.out.println("call method someVoidMethod");
}
public int foo() {
int i = 5;
someVoidMethod(i);
return i;
}
will be mutate to
public void someVoidMethod(int i) {
System.out.println("call method someVoidMethod");
}
public int foo() {
int i = 5;
return i;
}