aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-core-plugin/src/test
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-02-19 16:53:02 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-02-19 21:57:29 +0100
commita5627abf8dce968a864a2b57b910ad4bc1e8c9d5 (patch)
tree76c089451cd76219b8b90a0d83f0b3cd95c3a46e /plugins/sonar-core-plugin/src/test
parentccdf48e2a88d63c8b3c3041dcb6c1d0a6fa897d0 (diff)
downloadsonarqube-a5627abf8dce968a864a2b57b910ad4bc1e8c9d5.tar.gz
sonarqube-a5627abf8dce968a864a2b57b910ad4bc1e8c9d5.zip
SONAR-5772 Force coverage measure computation by default
Diffstat (limited to 'plugins/sonar-core-plugin/src/test')
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/MissingCoverageDecoratorTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/LinesToCoverDecoratorTest.java)21
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/LinesToCoverDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/MissingCoverageDecoratorTest.java
index 1b9d9c25f6d..45cb50cfd07 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/LinesToCoverDecoratorTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/MissingCoverageDecoratorTest.java
@@ -42,15 +42,15 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
-public class LinesToCoverDecoratorTest {
+public class MissingCoverageDecoratorTest {
private Settings settings;
- private LinesToCoverDecorator decorator;
+ private MissingCoverageDecorator decorator;
@Before
public void prepare() {
settings = new Settings(new PropertyDefinitions(CorePropertyDefinitions.all()));
- decorator = new LinesToCoverDecorator(settings);
+ decorator = new MissingCoverageDecorator(settings);
}
@Test
@@ -90,6 +90,21 @@ public class LinesToCoverDecoratorTest {
}
@Test
+ public void testUseNclocDataIfPossible() {
+ DecoratorContext context = mock(DecoratorContext.class);
+ File file = File.create("src/Foo.java");
+
+ when(context.getMeasure(CoreMetrics.LINES_TO_COVER)).thenReturn(null);
+ when(context.getMeasure(CoreMetrics.NCLOC_DATA)).thenReturn(new Measure<>(CoreMetrics.NCLOC_DATA, "1=0;2=1;3=0;4=1"));
+
+ decorator.decorate(file, context);
+
+ verify(context).saveMeasure(new Measure(CoreMetrics.LINES_TO_COVER, 2.0));
+ verify(context).saveMeasure(new Measure(CoreMetrics.UNCOVERED_LINES, 2.0));
+ verify(context).saveMeasure(new Measure(CoreMetrics.COVERAGE_LINE_HITS_DATA, "2=0;4=0"));
+ }
+
+ @Test
public void testUseNclocAsLinesToCover() {
DecoratorContext context = mock(DecoratorContext.class);
File file = File.create("src/Foo.java");