]> source.dussan.org Git - sonarqube.git/commitdiff
Improve code coverage
authorDavid Gageot <david@gageot.net>
Mon, 15 Oct 2012 13:39:29 +0000 (15:39 +0200)
committerDavid Gageot <david@gageot.net>
Mon, 15 Oct 2012 13:39:35 +0000 (15:39 +0200)
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ItCoverageDecoratorTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/OverallCoverageDecoratorTest.java

index 16efef23eb36dc60441323496c88f26396a1e3be..5334b5e1f7a63320fcfaea7fff1a02e4aacf44fe 100644 (file)
@@ -105,6 +105,17 @@ public class CoverageDecoratorTest {
     verify(context, never()).saveMeasure(eq(CoreMetrics.COVERAGE), anyDouble());
   }
 
+  @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);
index b8e3afb2162b174aeecc2507154e66ae9e655649..1f2d92ff6f9abd63b763159a314f630cb8bef187 100644 (file)
@@ -105,6 +105,17 @@ public class ItCoverageDecoratorTest {
     verify(context, never()).saveMeasure(eq(CoreMetrics.IT_COVERAGE), anyDouble());
   }
 
+  @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);
index 546f9b8e3127e7e7714295ecb8da749f024142fa..b35ee663c43b5d9ac15d0e2374b8d032cf3febc3 100644 (file)
@@ -105,6 +105,17 @@ public class OverallCoverageDecoratorTest {
     verify(context, never()).saveMeasure(eq(CoreMetrics.OVERALL_COVERAGE), anyDouble());
   }
 
+  @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);