diff options
author | David Gageot <david@gageot.net> | 2012-10-15 15:39:29 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-10-15 15:39:35 +0200 |
commit | 5d43317984537e25a6baba2b889fa035e631fb50 (patch) | |
tree | 631b17b1771e415d80a36593fb84d05e48a7a235 /plugins | |
parent | 4a4ef9fae8735177da8b6eba4e42321124b7d082 (diff) | |
download | sonarqube-5d43317984537e25a6baba2b889fa035e631fb50.tar.gz sonarqube-5d43317984537e25a6baba2b889fa035e631fb50.zip |
Improve code coverage
Diffstat (limited to 'plugins')
3 files changed, 33 insertions, 0 deletions
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java index 16efef23eb3..5334b5e1f7a 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java @@ -106,6 +106,17 @@ public class CoverageDecoratorTest { } @Test + public void should_count_elements_for_new_code() { + Measure newLines = measureWithVariation(1, 100.0); + Measure newConditions = measureWithVariation(1, 1.0); + DecoratorContext context = mockNewContext(newLines, null, null, newConditions); + + long count = decorator.countElementsForNewCode(context, 1); + + assertThat(count).isEqualTo(101).isEqualTo(100 + 1); + } + + @Test public void should_count_covered_elements_for_new_code() { Measure newLines = measureWithVariation(1, 100.0); Measure newUncoveredConditions = measureWithVariation(1, 10.0); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ItCoverageDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ItCoverageDecoratorTest.java index b8e3afb2162..1f2d92ff6f9 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ItCoverageDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ItCoverageDecoratorTest.java @@ -106,6 +106,17 @@ public class ItCoverageDecoratorTest { } @Test + public void should_count_elements_for_new_code() { + Measure newLines = measureWithVariation(1, 100.0); + Measure newConditions = measureWithVariation(1, 1.0); + DecoratorContext context = mockNewContext(newLines, null, null, newConditions); + + long count = decorator.countElementsForNewCode(context, 1); + + assertThat(count).isEqualTo(101).isEqualTo(100 + 1); + } + + @Test public void should_count_covered_elements_for_new_code() { Measure newLines = measureWithVariation(1, 100.0); Measure newUncoveredConditions = measureWithVariation(1, 10.0); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/OverallCoverageDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/OverallCoverageDecoratorTest.java index 546f9b8e312..b35ee663c43 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/OverallCoverageDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/OverallCoverageDecoratorTest.java @@ -106,6 +106,17 @@ public class OverallCoverageDecoratorTest { } @Test + public void should_count_elements_for_new_code() { + Measure newLines = measureWithVariation(1, 100.0); + Measure newConditions = measureWithVariation(1, 1.0); + DecoratorContext context = mockNewContext(newLines, null, null, newConditions); + + long count = decorator.countElementsForNewCode(context, 1); + + assertThat(count).isEqualTo(101).isEqualTo(100 + 1); + } + + @Test public void should_count_covered_elements_for_new_code() { Measure newLines = measureWithVariation(1, 100.0); Measure newUncoveredConditions = measureWithVariation(1, 10.0); |