Java | Mutation Testing | PiTEST | (negated conditional → SURVIVED) | (changed conditional boundary → SURVIVED)

939 Views Asked by At

I am getting piTest issues. Few mutations are getting survived.

PiTEST negated conditional → SURVIVED changed conditional boundary → SURVIVED

As per my understanding i am testing boundary conditions for a>=5 i.e. a=4, a=5, a=6. Do i need to add some other conditions?

  • negated conditional → SURVIVED &
  • changed conditional boundary → SURVIVED

CODE

public static Boolean test(Integer a) {
    if (a >= 5) {
        return false;
    }
    return true;
}

For the above code I have written the following Test Case:

TESTCASE

@Test
public void test1() {
    assertEquals(false, service.test(5));
    assertEquals(false, service.test(6));
    assertEquals(true, service.test(4));           
                
    //        assertTrue(service.test(0));
    //        assertTrue(service.test(-1));
    //        assertTrue(service.test(0));
    //        assertNotNull(service.test(5));
    //        assertNull(service.test(null));
}
1

There are 1 best solutions below

0
RagaSGNur On

Try to test by adding the assert statements like,

  assertThat(service.test(5)).isFalse();
  assertThat(service.test(6)).isFalse();
  assertThat(service.test(4)).isTrue();