private Collection<ClassName> allClasses() { return this.code.getCodeUnderTestNames(); }
private Set<ClassName> getAllClassesAndTests( final CoverageDatabase coverageData) { final Set<ClassName> names = new HashSet<>(); for (final ClassName each : this.code.getCodeUnderTestNames()) { names.add(each); FCollection.mapTo(coverageData.getTestsForClass(each), TestInfo.toDefiningClassName(), names); } return names; }
@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 shouldProvideNamesOfCodeClasses() { final ClassInfo foo = makeClassInfo("Foo"); final ClassInfo bar = makeClassInfo("Bar"); when(this.classPath.code()).thenReturn( Arrays.asList(foo.getName(), bar.getName())); assertThat(this.testee.getCodeUnderTestNames()).containsOnly(ClassName.fromString("Foo") , ClassName.fromString("Bar")); }
@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 shouldIncludeAllCoveredLinesInCoverageSummary() { final BlockLocationBuilder block = aBlockLocation(); when(this.code.getCodeUnderTestNames()).thenReturn( Collections.singleton(block.build().getLocation().getClassName())); when(this.lm.mapLines(any(ClassName.class))).thenReturn( makeCoverageMapForBlock(block, 1, 2, 3, 4)); final CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks( block.build(1)); this.testee.calculateClassCoverage(cr.build()); final CoverageSummary actual = this.testee.createSummary(); assertEquals(4, actual.getNumberOfCoveredLines()); }
private List<MutationAnalysisUnit> buildMutationTests( final CoverageDatabase coverageData, final MutationEngine engine, EngineArguments args) { final MutationConfig mutationConfig = new MutationConfig(engine, coverage() .getLaunchOptions()); final ClassByteArraySource bas = fallbackToClassLoader(new ClassPathByteArraySource( this.data.getClassPath())); final TestPrioritiser testPrioritiser = this.settings.getTestPrioritiser() .makeTestPrioritiser(this.data.getFreeFormProperties(), this.code, coverageData); final MutationInterceptor interceptor = this.settings.getInterceptor() .createInterceptor(this.data, bas); final MutationSource source = new MutationSource(mutationConfig, testPrioritiser, bas, interceptor); final MutationAnalyser analyser = new IncrementalAnalyser( new DefaultCodeHistory(this.code, history()), coverageData); final WorkerFactory wf = new WorkerFactory(this.baseDir, coverage() .getConfiguration(), mutationConfig, args, new PercentAndConstantTimeoutStrategy(this.data.getTimeoutFactor(), this.data.getTimeoutConstant()), this.data.isVerbose(), this.data.isFullMutationMatrix(), this.data.getClassPath().getLocalClassPath()); final MutationGrouper grouper = this.settings.getMutationGrouper().makeFactory( this.data.getFreeFormProperties(), this.code, this.data.getNumberOfThreads(), this.data.getMutationUnitSize()); final MutationTestBuilder builder = new MutationTestBuilder(wf, analyser, source, grouper); return builder.createMutationTestUnits(this.code.getCodeUnderTestNames()); }