private Collection<MutationDetails> someMutations() { return aMutationDetail().build(2); }
public static MutationDetails makeMutation() { return makeMutation(ClassName.fromString("foo")); }
public static MutationDetailsBuilder aMutationDetail() { return QB.builder(MutationDetailsBuilder.class, seed()).withBlock(0) .withDescription("A mutation").withFilename("foo.java") .withId(aMutationId()).withLineNumber(42).withIsInFinallyBlock(false) .withPoison(PoisonStatus.NORMAL).withTestsInOrder(Collections.<TestInfo> emptyList()); }
@Test public void shouldReportPriorityBasedOnNumberOfMutations() { this.mutations.add(MutationDetailsMother.aMutationDetail().build()); this.testee = new MutationTestUnit(MutationDetailsMother.aMutationDetail() .build(42), this.tests, null); assertThat(this.testee.priority()).isEqualTo(42); }
@Test public void shouldCreateNewCopyWithUpdatedPoisonStatusForStaticInitializerMarking() { final MutationDetails testee = MutationDetailsMother.aMutationDetail().build(); final MutationDetails actual = testee.withPoisonStatus(PoisonStatus.IS_STATIC_INITIALIZER_CODE); assertThat(actual).isNotSameAs(testee); assertThat(actual.mayPoisonJVM()).isTrue(); assertThat(actual.isInStaticInitializer()).isTrue(); }
@Test public void shouldChainModifiedMutantListsThroughChildrenInCorrectOrder() { // add out of order this.testee = new CompoundMutationInterceptor(Arrays.asList(this.cosmeticChild, this.otherChild, this.modifyChild, this.reportChild, this.filterChild)); final Collection<MutationDetails> original = aMutationDetail().build(1); final Collection<MutationDetails> modifyResult = aMutationDetail().build(2); final Collection<MutationDetails> filterResult = aMutationDetail().build(3); final Collection<MutationDetails> reportResult = aMutationDetail().build(3); final Collection<MutationDetails> cosmeticResult = aMutationDetail().build(3); final Collection<MutationDetails> otherResult = aMutationDetail().build(3); when(this.modifyChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(modifyResult); when(this.filterChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(filterResult); when(this.reportChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(reportResult); when(this.cosmeticChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(cosmeticResult); when(this.otherChild.intercept(any(Collection.class), any(Mutater.class))).thenReturn(otherResult); final Collection<MutationDetails> actual = this.testee.intercept(original, this.mutater); assertThat(actual).isEqualTo(reportResult); verify(this.otherChild).intercept(original,this.mutater); verify(this.modifyChild).intercept(otherResult,this.mutater); verify(this.filterChild).intercept(modifyResult,this.mutater); verify(this.cosmeticChild).intercept(cosmeticResult,this.mutater); verify(this.reportChild).intercept(cosmeticResult,this.mutater); }
@Test public void shouldCreateNewCopyWithUpdatedPoisonStatusForJVMPoisoningMarking() { final MutationDetails testee = MutationDetailsMother.aMutationDetail().build(); final MutationDetails actual = testee.withPoisonStatus(PoisonStatus.MAY_POISON_JVM); assertThat(actual).isNotSameAs(testee); assertThat(actual.mayPoisonJVM()).isTrue(); }
@Test public void shouldNotFilterNotStaticMutants() { final Collection<MutationDetails> unmarked = aMutationDetail() .build(2); assertThat(this.testee.intercept(unmarked, null)).containsAll(unmarked); }
@Test public void shouldRemoveMutationsInStaticInitCode() { final Collection<MutationDetails> marked = aMutationDetail() .withPoison(PoisonStatus.IS_STATIC_INITIALIZER_CODE) .build(2); assertThat(this.testee.intercept(marked, null)).isEmpty(); }
@Test @Ignore("is triggering filter with fake classes") public void shouldReportMutationsFoundWhenSomeDetected() { this.data.setFailWhenNoMutations(false); final ClassName foo = ClassName.fromClass(Foo.class); when(this.mutater.findMutations(foo)).thenReturn( MutationDetailsMother.aMutationDetail().build(1)); when(this.code.getCodeUnderTestNames()).thenReturn( Collections.singleton(foo)); final CombinedStatistics actual = createAndRunTestee(); assertEquals(1, actual.getMutationStatistics().getTotalMutations()); }
@Test public void shouldNotFilterMutationsInLineZeroOfAJavaClass() { final List<MutationDetails> mutations = MutationDetailsMother.aMutationDetail() .withFilename("Foo.java") .withLineNumber(0) .build(0); assertThat(this.testee.intercept(mutations, this.unused)).containsAll(mutations); }
@Test public void shouldFilterMutationsInLineZeroOfAKotlinClass() { final List<MutationDetails> mutations = MutationDetailsMother.aMutationDetail() .withFilename("Foo.kt") .withLineNumber(0) .build(0); assertThat(this.testee.intercept(mutations, this.unused)).isEmpty(); }
@Test public void shouldNotCareAboutCaseOfKotlinfileExtension() { final List<MutationDetails> mutations = MutationDetailsMother.aMutationDetail() .withFilename("Foo.kT") .withLineNumber(0) .build(0); assertThat(this.testee.intercept(mutations, this.unused)).isEmpty(); }
@Test public void shouldNotFilterMutationsOhterLinesOfAKotlinClass() { final List<MutationDetails> mutations = MutationDetailsMother.aMutationDetail() .withFilename("Foo.kt") .withLineNumber(1) .build(0); assertThat(this.testee.intercept(mutations, this.unused)).containsAll(mutations); }
@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(); }
private MutationResult makeResult(String clazz, String method) { final Location location = Location.location(ClassName.fromString(clazz), MethodName.fromString(method), "()V"); final MutationDetails md = aMutationDetail().withId( aMutationId().withLocation(location)).build(); final MutationResult mr = new MutationResult(md, MutationStatusTestPair.notAnalysed(0, DetectionStatus.KILLED)); return mr; }