0

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));
}
samabcde
  • 6,988
  • 2
  • 25
  • 41
satyam pandey
  • 43
  • 1
  • 7
  • I've tried your test in my IntelliJ with the pitest plugin and everything was fine. But I have sometimes trouble with outdated compiled test class files. Try to clean your compiled test classes and rerun your pitest. Hope this will help. – Timo Jul 25 '22 at 18:18

1 Answers1

0

Try to test by adding the assert statements like,

  assertThat(service.test(5)).isFalse();
  assertThat(service.test(6)).isFalse();
  assertThat(service.test(4)).isTrue();
RagaSGNur
  • 199
  • 1
  • 2
  • 15