pitest / pitclipse

Mutation testing for Java in Eclipse IDE. Based on PIT (Pitest).
https://pitest.org
Apache License 2.0
59 stars 17 forks source link

Using the eclipse plugin for Pit test in Java. Facing an error - Tests failing without mutation #192

Closed ja9563803 closed 2 years ago

ja9563803 commented 2 years ago

Hi, I am using the eclipse plug in - pitclipse for pit testing in Java. I created a project using Java SE -1.8 and JUnit 4 for the tests.

The following is my code and tests.

Code

    public class trial1 {
    boolean productIsEven(int a, int b){

    int product = 2 %(a * b);
    boolean evenOr = product == 1;
    return evenOr;
         }
    }

Tests

    import static org.junit.Assert.*;
    import org.junit.Before;
    import org.junit.Test;

    public class trial1Test {

trial1 obj;
@Before
public void setUp()
{
    obj=new trial1();
}

@Test
public void testTrue1() {

    assertEquals(true, obj.productIsEven(10, 20));
}

@Test
public void testTrue2() {

    assertEquals(true, obj.productIsEven(2, 17));
}

@Test
public void testTrue3() {

    assertEquals(true, obj.productIsEven(0, 0));
}

@Test
public void testTrue4() {

    assertEquals(true, obj.productIsEven(0, 1));
}

@Test
public void testTrue5() {

    assertEquals(true, obj.productIsEven(2, 15));
}

@Test
public void testTrue6() {

    assertEquals(true, obj.productIsEven(2, 13));
}

@Test
public void testFalse1() {

    assertEquals(false, obj.productIsEven(5, 5));
}

@Test
public void testFalse2() {

    assertEquals(false, obj.productIsEven(1, 13));
}

@Test
public void testFalse3() {

    assertEquals(false, obj.productIsEven(1, 15));
}

@Test
public void testFalse4() {

    assertEquals(false, obj.productIsEven(1, 17));
}
    }

.

.

I receive the following error while trying to do the pit test, not sure how to overcome this error.

3:34:50 PIT >> SEVERE : Tests failing without mutation: Description [testClass=trial1Test, name=testTrue1(trial1Test)] Description [testClass=trial1Test, name=testTrue2(trial1Test)] Description [testClass=trial1Test, name=testTrue3(trial1Test)] Description [testClass=trial1Test, name=testTrue4(trial1Test)] Description [testClass=trial1Test, name=testTrue5(trial1Test)] Description [testClass=trial1Test, name=testTrue6(trial1Test)] Exception in thread "main" org.pitest.help.PitHelpError: 6 tests did not pass without mutation when calculating line coverage. Mutation testing requires a green suite

.

.

Below is the PIT test coverage report I receive.

1

LorenzoBettini commented 2 years ago

It means that some of your tests are failing independently from mutation testing

LorenzoBettini commented 2 years ago

I'm closing this since from what I understand it's not an issue with PIT; in case, please re-open it