@Override public final void execute() throws MojoExecutionException, MojoFailureException { switchLogging(); RunDecision shouldRun = shouldRun(); if (shouldRun.shouldRun()) { for (final ToolClasspathPlugin each : this.plugins .findToolClasspathPlugins()) { this.getLog().info("Found plugin : " + each.description()); } for (final ClientClasspathPlugin each : this.plugins .findClientClasspathPlugins()) { this.getLog().info( "Found shared classpath plugin : " + each.description()); } final Optional<CombinedStatistics> result = analyse(); if (result.isPresent()) { throwErrorIfScoreBelowThreshold(result.get().getMutationStatistics()); throwErrorIfMoreThanMaximumSurvivors(result.get().getMutationStatistics()); throwErrorIfCoverageBelowThreshold(result.get().getCoverageSummary()); } } else { this.getLog().info("Skipping project because:"); for (String reason : shouldRun.getReasons()) { this.getLog().info(" - " + reason); } } }
return new CombinedStatistics(stats.getStatistics(), coverageData.createSummary());
@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()); }
public static void main(final String[] args) { final PluginServices plugins = PluginServices.makeForContextLoader(); final OptionsParser parser = new OptionsParser(new PluginFilter(plugins)); final ParseResult pr = parser.parse(args); if (!pr.isOk()) { parser.printHelp(); System.out.println(">>>> " + pr.getErrorMessage().get()); } else { final ReportOptions data = pr.getOptions(); final CombinedStatistics stats = runReport(data, plugins); throwErrorIfScoreBelowCoverageThreshold(stats.getCoverageSummary(), data.getCoverageThreshold()); throwErrorIfScoreBelowMutationThreshold(stats.getMutationStatistics(), data.getMutationThreshold()); throwErrorIfMoreThanMaxSuvivingMutants(stats.getMutationStatistics(), data.getMaximumAllowedSurvivors()); } }
@Override public final void execute() throws MojoExecutionException, MojoFailureException { switchLogging(); RunDecision shouldRun = shouldRun(); if (shouldRun.shouldRun()) { for (final ToolClasspathPlugin each : this.plugins .findToolClasspathPlugins()) { this.getLog().info("Found plugin : " + each.description()); } for (final ClientClasspathPlugin each : this.plugins .findClientClasspathPlugins()) { this.getLog().info( "Found shared classpath plugin : " + each.description()); } final Optional<CombinedStatistics> result = analyse(); if (result.isPresent()) { throwErrorIfScoreBelowThreshold(result.get().getMutationStatistics()); throwErrorIfMoreThanMaximumSurvivors(result.get().getMutationStatistics()); throwErrorIfCoverageBelowThreshold(result.get().getCoverageSummary()); } } else { this.getLog().info("Skipping project because:"); for (String reason : shouldRun.getReasons()) { this.getLog().info(" - " + reason); } } }