From 6a16dd3b828585d2a2fbd0127c3ea56c40a9ebba Mon Sep 17 00:00:00 2001 From: Henry Coles Date: Tue, 1 Jun 2021 10:33:11 +0100 Subject: [PATCH] re-apply #797 --- .../tooling/MutationCoverage.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java b/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java index 0a990a89d..7ec27e6aa 100644 --- a/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java +++ b/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java @@ -182,10 +182,12 @@ private CombinedStatistics runAnalysis(Runtime runtime, long t0, EngineArguments LOG.info("Completed in " + timeSpan(t0)); - printStats(stats); + CombinedStatistics combined = new CombinedStatistics(stats.getStatistics(), + coverageData.createSummary()); - return new CombinedStatistics(stats.getStatistics(), - coverageData.createSummary()); + printStats(combined); + + return combined; } private Predicate allInterceptors() { @@ -274,13 +276,14 @@ private void verifyBuildSuitableForMutationTesting() { this.strategies.buildVerifier().verify(this.code); } - private void printStats(final MutationStatisticsListener stats) { + private void printStats(CombinedStatistics combinedStatistics) { + MutationStatistics stats = combinedStatistics.getMutationStatistics(); final PrintStream ps = System.out; ps.println(StringUtil.separatorLine('=')); ps.println("- Mutators"); ps.println(StringUtil.separatorLine('=')); - for (final Score each : stats.getStatistics().getScores()) { + for (final Score each : stats.getScores()) { each.report(ps); ps.println(StringUtil.separatorLine()); } @@ -293,7 +296,14 @@ private void printStats(final MutationStatisticsListener stats) { ps.println(StringUtil.separatorLine('=')); ps.println("- Statistics"); ps.println(StringUtil.separatorLine('=')); - stats.getStatistics().report(ps); + + final CoverageSummary coverage = combinedStatistics.getCoverageSummary(); + if (coverage != null) { + ps.println(String.format(">> Line Coverage: %d/%d (%d%%)", coverage.getNumberOfCoveredLines(), + coverage.getNumberOfLines(), coverage.getCoverage())); + } + + stats.report(ps); } private List buildMutationTests(CoverageDatabase coverageData,