Hi,
I am playing around with pitest and trying to create a simple example that I present to coworkers to explain mutation testing and pitest. The goal is to show my coworkers what pitest can do to help improve our tests and give an overview of how mutation testing works. I created a Person class and a PersonTest class that provides 100% code coverage but really doesn't test anything.
Here is my class
public class Person {
public String firstName;
public String lastName;
public Integer age;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public boolean isOldEnoughToDrink() {
return age != null && age.intValue() >= 19;
}
}and here is my test
@Test
public void testPerson() {
Person person = new Person();
person.setFirstName("Money");
person.setLastName("Penny");
person.setAge(new Integer(21));
Assert.assertNotNull(person.getAge());
Assert.assertNotNull(person.getFirstName());
Assert.assertNotNull(person.getLastName());
person.isOldEnoughToDrink();
person.setAge(null);
person.isOldEnoughToDrink();
person.setAge(new Integer(17));
person.isOldEnoughToDrink();
}
Now my test is kind of useless because it doesn't really assert anything except for non nullables. However when I run pitest it actually passes on all mutations on the getters and setters. This seems strange to me as my test is obviously no good. If I rem
Is there a mutator I can use that will mutate the return value of my getters (example add a "1" at the end) ?
Is there a mutator I can use that will mutate the set value of my setters (similar idea as above) ?
Any other ways I can prove that this test is inadequate ?
Thanks
Daryl