Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Report 100% for empty Coverage objects #79

Merged
merged 1 commit into from
Feb 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified resources/test/multiple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/jacoco/model/Coverage.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public int getPercentage() {
public float getPercentageFloat() {
float numerator = covered;
float denominator = missed + covered;
return denominator <= 0 ? 0 : 100 * (numerator / denominator);
return denominator <= 0 ? 100 : 100 * (numerator / denominator);
}

public CoverageElement.Type getType() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/hudson/plugins/jacoco/CoverageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testNormalConstructorInitializes() throws Exception {

@Test
public void testVacuousCoverage() throws Exception {
Coverage c = new Coverage(0, 0);
assertEquals(0, c.getPercentage());
final Coverage c = new Coverage(0, 0);
assertEquals(100, c.getPercentage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ public void skipZero() throws IOException

private TestCoverageObject createTestCoverage()
{
TestCoverageObject t5 = new TestCoverageObject().branch(6, 30).line(5000, 19000);
TestCoverageObject t4 = new TestCoverageObject().branch(6, 0).line(5000, 19000).previous(t5);
TestCoverageObject t3 = new TestCoverageObject().branch(6, 35).line(5000, 19000).previous(t4);
TestCoverageObject t2 = new TestCoverageObject().branch(15, 23).line(10000, 15000).previous(t3);
TestCoverageObject t1 = new TestCoverageObject().branch(27, 13).line(12000, 18000).previous(t2);
TestCoverageObject t0 = new TestCoverageObject().previous(t1);
final TestCoverageObject t5 = new TestCoverageObject().branch(6, 30).line(5000, 19000);
final TestCoverageObject t4 = new TestCoverageObject().branch(6, 0).line(5000, 19000).previous(t5);
final TestCoverageObject t3 = new TestCoverageObject().branch(6, 35).line(5000, 19000).previous(t4);
final TestCoverageObject t2 = new TestCoverageObject().branch(15, 23).line(10000, 15000).previous(t3);
final TestCoverageObject t1 = new TestCoverageObject().branch(27, 13).line(12000, 18000).previous(t2);
final TestCoverageObject t0 = new TestCoverageObject().branch(40, 0).previous(t1);
ctl.replay();
return t0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ protected synchronized void saveNextBuildNumber() throws IOException {
}
};
assertTrue(jacocoColumn.hasCoverage(mockJob));
assertEquals("0.0", jacocoColumn.getPercent(mockJob));
assertEquals(new BigDecimal("0.0"), jacocoColumn.getLineCoverage(mockJob));
assertEquals("100.0", jacocoColumn.getPercent(mockJob));
assertEquals(new BigDecimal("100.0"), jacocoColumn.getLineCoverage(mockJob));

EasyMock.verify(context);
}

@Test
public void testGetLineColorWithNull() throws Exception {
assertNull(jacocoColumn.getLineColor(null, null));
Expand Down