private static void throwErrorIfScoreBelowCoverageThreshold( CoverageSummary stats, int threshold) { if ((threshold != 0) && (stats.getCoverage() < threshold)) { throw new RuntimeException("Line coverage of " + stats.getCoverage() + " is below threshold of " + threshold); } }
private void throwErrorIfCoverageBelowThreshold( final CoverageSummary coverageSummary) throws MojoFailureException { if ((this.coverageThreshold != 0) && (coverageSummary.getCoverage() < this.coverageThreshold)) { throw new MojoFailureException("Line coverage of " + coverageSummary.getCoverage() + "(" + coverageSummary.getNumberOfCoveredLines() + "/" + coverageSummary.getNumberOfLines() + ") is below threshold of " + this.coverageThreshold); } }
@Test public void shouldCorrectlyCalculateLineCoverageWhenPartiallyCovered() { assertEquals(50, new CoverageSummary(100, 50).getCoverage()); }
@Test public void shouldCorrectlyCalculateLineCoverageWhenAllLinesCovered() { assertEquals(100, new CoverageSummary(100, 100).getCoverage()); }
@Test public void shouldCorrectlyCalculateLineCoverageWhenNoLinesPresent() { assertEquals(100, new CoverageSummary(0, 0).getCoverage()); }
@Test public void shouldCorrectlyCalculateLineCoverageWhenNoLinesCovered() { assertEquals(0, new CoverageSummary(100, 0).getCoverage()); }
private void throwErrorIfCoverageBelowThreshold( final CoverageSummary coverageSummary) throws MojoFailureException { if ((this.coverageThreshold != 0) && (coverageSummary.getCoverage() < this.coverageThreshold)) { throw new MojoFailureException("Line coverage of " + coverageSummary.getCoverage() + "(" + coverageSummary.getNumberOfCoveredLines() + "/" + coverageSummary.getNumberOfLines() + ") is below threshold of " + this.coverageThreshold); } }