I'm starting to dig into Code Analysis and mutants. I'm using PITest as a plugin on my eclipse Project. I ran into this mutant that I can't kill. Suppose I have the following code.
class Mutation{
public static void main(String [] args){
int i=0;
String SPECIAL_CHARS = "?!$@";
String password = "Something";
for (int pos = 0; pos < password.length(); pos++) {
char c = password.charAt(pos);
if(SPECIAL_CHARS.indexOf(c) < 0) {
i++;
}
}
}
}
As far as my understanding goes, If there's a char that doesn't belong to SPECIAL_CHARS
(say (
), variable i
will increment. PITest reports two mutants.
With the following information.
I tried to write several Junit test that may kill this mutant without any luck. Can someone please explain me how is it possible to kill it?
I know now, that if my password has ?
as the first char of the String password
the conditional boundary check may be killed. What about the increment? What does it mean?