Skip to content

Commit

Permalink
JENKINS-22412 Added test for new getMetricsWithEmpty() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamini committed Mar 31, 2014
1 parent 265f34f commit 35eada4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/test/java/hudson/plugins/cobertura/CoverageResultTest.java
Expand Up @@ -5,7 +5,9 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
Expand Down Expand Up @@ -79,6 +81,18 @@ public void testGetResults() throws Exception {
ctl.verify();
}

/**
* Test behavior of {@link CoverageResult#getMetricsWithEmpty()}.
*/
public void testGetMetricsWithEmpty() throws Exception {
ctl.replay();
CoverageResult result = loadResults("coverage-no-data.xml");
Set<CoverageMetric> metrics = result.getMetricsWithEmpty();
List<CoverageMetric> allMetrics = new LinkedList<CoverageMetric>(Arrays.asList(CoverageMetric.PACKAGES, CoverageMetric.FILES, CoverageMetric.CLASSES, CoverageMetric.METHOD, CoverageMetric.LINE, CoverageMetric.CONDITIONAL));
assertEquals(metrics.size(), allMetrics.size());
ctl.verify();
}

/**
* Tests the behavior of {@link CoverageResult#getParent()}.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/test/resources/hudson/plugins/cobertura/coverage-no-data.xml
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd"-->

<coverage line-rate="0.0" branch-rate="0.0" version="1.9" timestamp="1187353747005">
<sources>
<source>C:/local/mvn-coverage-example/src/main/java</source>
</sources>
<packages/>
<classes/>
<methods/>
<lines/>
<classes/>
<packages/>
</coverage>

0 comments on commit 35eada4

Please sign in to comment.