Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vivganes committed Aug 13, 2024
1 parent d317859 commit 25a8460
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@

import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;

import com.google.common.collect.Lists;
import org.junit.Before;
import org.junit.Test;
import org.pitest.classinfo.ClassName;
import org.pitest.coverage.TestInfo;
import org.pitest.mutationtest.LocationMother.MutationIdentifierBuilder;
import org.pitest.mutationtest.engine.MutationDetails;

Expand All @@ -23,12 +27,18 @@ public class MutationStatusMapTest {

private MutationDetails detailsTwo;

private MutationDetails aSurvivedMutationDetails;

@Before
public void setUp() {
this.testee = new MutationStatusMap();
final MutationIdentifierBuilder id = aMutationId().withIndex(1);
this.details = aMutationDetail().withId(id.withIndex(1)).build();
this.detailsTwo = aMutationDetail().withId(id.withIndex(2)).build();

TestInfo fooTest = new TestInfo("foo", "foo", 0, Optional.ofNullable(ClassName.fromString("com.foo")), 0);
TestInfo barTest = new TestInfo("bar", "bar", 0, Optional.ofNullable(ClassName.fromString("com.foo")), 0);
this.aSurvivedMutationDetails = aMutationDetail().withId(id.withIndex(3)).withTestsInOrder(Lists.asList(fooTest, new TestInfo[]{barTest})).build();
}

@Test
Expand Down Expand Up @@ -92,6 +102,18 @@ public void shouldCreateResultsForAllMutations() {
resultTwo);
}

@Test
public void shouldCreateResultsForSurvivedMutations(){
final MutationStatusTestPair statusPairOne = new MutationStatusTestPair(42,
DetectionStatus.SURVIVED, "foo");
this.testee.setStatusForMutation(this.aSurvivedMutationDetails, statusPairOne);

assertEquals(DetectionStatus.SURVIVED, this.testee.createMutationResults().get(0).getStatus());
assertThat(this.testee.createMutationResults().get(0).getKillingTests()).contains("foo");
assertThat(this.testee.createMutationResults().get(0).getSucceedingTests()).contains("foo","bar");

}

@Test
public void shouldSetStatusToUncoveredWhenMutationHasNoTests() {
this.testee.setStatusForMutations(
Expand Down

0 comments on commit 25a8460

Please sign in to comment.