Skip to content

Instantly share code, notes, and snippets.

@jreyes33
Last active August 29, 2015 14:21
Embed
What would you like to do?
pitest weak tests http://pitest.org/weak_tests/
public static String foo(boolean b) {
if ( b ) {
performVitallyImportantBusinessFunction();
return "OK";
}
return "FAIL";
}
@Test
public void shouldFailWhenGivenFalse() {
assertEquals("FAIL", foo(false));
}
@Test
public void shouldBeOkWhenGivenTrue() {
assertEquals("OK", foo(true));
}
public static String foo(int i) {
if ( i >= 0 ) {
return "foo";
} else {
return "bar";
}
}
@Test
public void shouldReturnBarWhenGiven1() {
assertEquals("bar", foo(1));
}
@Test
public void shouldReturnFooWhenGivenMinus1() {
assertEquals("foo", foo(-1));
}
public static String foo(Collaborator c, boolean b) {
if ( b ) {
return c.performAction();
}
return "FOO";
}
@Test
public void shouldPerformActionWhenGivenTrue() {
foo(mockCollaborator,true);
verify(mockCollaborator).performAction();
}
@Test
public void shouldNotPerformActionWhenGivenFalse() {
foo(mockCollaborator,false);
verify(never(),mockCollaborator).performAction();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment