diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-25 11:44:52 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-25 11:44:52 +0100 |
commit | 70961f0058aaf7eddf739cba89d19f0b86ad5c85 (patch) | |
tree | 81f80d26ecd778d61f72306243170e14b168bfe1 /sonar-plugin-api/src/test/java | |
parent | 5633520d8220bd9635fc8c0ef5939170442d7db4 (diff) | |
download | sonarqube-70961f0058aaf7eddf739cba89d19f0b86ad5c85.tar.gz sonarqube-70961f0058aaf7eddf739cba89d19f0b86ad5c85.zip |
API: fix CoverageMeasuresBuilder for Cobertura
Diffstat (limited to 'sonar-plugin-api/src/test/java')
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/measures/CoverageMeasuresBuilderTest.java | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/CoverageMeasuresBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/CoverageMeasuresBuilderTest.java index 12c43709c37..1d72a1b194f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/CoverageMeasuresBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/CoverageMeasuresBuilderTest.java @@ -43,13 +43,6 @@ public class CoverageMeasuresBuilderTest { assertThat(find(builder.createMeasures(), CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY).getData(), is("1=0;2=3;4=2")); } - @Test(expected = IllegalArgumentException.class) - public void shouldFailIfDuplicatedLineHits() { - CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); - builder.setHits(1, 0); - builder.setHits(1, 3); - } - @Test public void shouldCreateUncoveredLines() { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); @@ -64,9 +57,8 @@ public class CoverageMeasuresBuilderTest { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); builder.setConditions(1, 2, 2); builder.setConditions(2, 1, 0); - assertThat(find(builder.createMeasures(), CoreMetrics.CONDITIONS_BY_LINE_DATA_KEY).getData(), is("1=2;2=1")); - assertThat(find(builder.createMeasures(), CoreMetrics.COVERED_CONDITIONS_BY_LINE_DATA_KEY).getData(), is("1=2;2=0")); - assertThat(find(builder.createMeasures(), CoreMetrics.BRANCH_COVERAGE_HITS_DATA_KEY).getData(), is("1=100%;2=0%")); + assertThat(find(builder.createMeasures(), CoreMetrics.CONDITIONS_BY_LINE_KEY).getData(), is("1=2;2=1")); + assertThat(find(builder.createMeasures(), CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY).getData(), is("1=2;2=0")); } @Test @@ -91,18 +83,32 @@ public class CoverageMeasuresBuilderTest { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); builder.setConditions(1, 0, 0); builder.setConditions(2, 1, 0); - assertThat(find(builder.createMeasures(), CoreMetrics.CONDITIONS_BY_LINE_DATA_KEY).getData(), is("2=1")); - assertThat(find(builder.createMeasures(), CoreMetrics.COVERED_CONDITIONS_BY_LINE_DATA_KEY).getData(), is("2=0")); - assertThat(find(builder.createMeasures(), CoreMetrics.BRANCH_COVERAGE_HITS_DATA_KEY).getData(), is("2=0%")); + assertThat(find(builder.createMeasures(), CoreMetrics.CONDITIONS_BY_LINE_KEY).getData(), is("2=1")); + assertThat(find(builder.createMeasures(), CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY).getData(), is("2=0")); } - @Test(expected = IllegalArgumentException.class) - public void shouldFailIfDuplicatedLineConditions() { + @Test + public void shouldIgnoreDuplicatedSetHits() { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); - builder.setConditions(1, 3, 0); - builder.setConditions(1, 3, 1); + builder.setHits(2, 3); + builder.setHits(2, 5);// to ignore + assertThat(builder.getLinesToCover(), is(1)); + assertThat(builder.getCoveredLines(), is(1)); + assertThat(builder.getHitsByLine().get(2), is(3)); + } + + @Test + public void shouldIgnoreDuplicatedSetConditions() { + CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); + builder.setConditions(1, 3, 2); + builder.setConditions(1, 1, 0);// to ignore + assertThat(builder.getConditions(), is(3)); + assertThat(builder.getCoveredConditions(), is(2)); + assertThat(builder.getConditionsByLine().get(1), is(3)); + assertThat(builder.getCoveredConditionsByLine().get(1), is(2)); } + @Test public void shouldResetFields() { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); |