@Test public void shouldCheckBuildSuitableForMutationTesting() { createAndRunTestee(); verify(this.verifier).verify(any(CodeSource.class)); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.data = new ReportOptions(); this.data.setSourceDirs(Collections.<File> emptyList()); when(this.coverage.calculateCoverage()).thenReturn(this.coverageDb); when( this.listenerFactory.getListener(Matchers.<Properties> any(), any(ListenerArguments.class))).thenReturn(this.listener); mockMutationEngine(); }
@Test public void shouldRecordClassPath() { final ClassName clazz = ClassName.fromClass(Foo.class); final HierarchicalClassId fooId = new HierarchicalClassId( new ClassIdentifier(0, clazz), "0"); final ClassInfo foo = ClassInfoMother.make(fooId.getId()); when(this.code.getCodeUnderTestNames()).thenReturn( Collections.singleton(clazz)); when(this.code.getClassInfo(any(List.class))).thenReturn( Collections.singletonList(foo)); createAndRunTestee(); verify(this.history).recordClassPath(Arrays.asList(fooId), this.coverageDb); }
@Test public void shouldNotReportErrorWhenNoMutationsFoundAndFlagNotSet() { try { this.data.setFailWhenNoMutations(false); createAndRunTestee(); } catch (final PitHelpError phe) { fail(); } }
@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 shouldReportNoMutationsFoundWhenNoneDetected() { this.data.setFailWhenNoMutations(false); final CombinedStatistics actual = createAndRunTestee(); assertEquals(0, actual.getMutationStatistics().getTotalMutations()); }
@Test public void shouldReportErrorWhenNoMutationsFoundAndFlagSet() { try { this.data.setFailWhenNoMutations(true); createAndRunTestee(); } catch (final PitHelpError phe) { assertEquals(Help.NO_MUTATIONS_FOUND.toString(), phe.getMessage()); } }