aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-jacoco-plugin
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-10-03 16:32:10 +0200
committerDavid Gageot <david@gageot.net>2012-10-04 08:00:35 +0200
commite835d2c8469ed045b262849b3816054625cf16c2 (patch)
tree87b484b309b76e3ee49285f3704bc5b12707356c /plugins/sonar-jacoco-plugin
parent6f999f3f1a8ac68bf9940cab7b8b84e94126093d (diff)
downloadsonarqube-e835d2c8469ed045b262849b3816054625cf16c2.tar.gz
sonarqube-e835d2c8469ed045b262849b3816054625cf16c2.zip
SONAR-2804 changes based on feedback
Diffstat (limited to 'plugins/sonar-jacoco-plugin')
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java (renamed from plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAllTestsSensor.java)34
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java2
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java (renamed from plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest.java)16
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec (renamed from plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest/it.exec)bin5862 -> 5862 bytes
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec (renamed from plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest/ut.exec)bin5850 -> 5850 bytes
5 files changed, 26 insertions, 26 deletions
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAllTestsSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
index 79a24239cb4..8ce1aa6e51e 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAllTestsSensor.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
@@ -42,12 +42,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
-public class JaCoCoAllTestsSensor implements Sensor {
- private static final String MERGED_EXEC = "target/sonar/merged.exec";
+public class JaCoCoOverallSensor implements Sensor {
+ private static final String JACOCO_OVERALL = "target/sonar/jacoco-overall.exec";
private final JacocoConfiguration configuration;
- public JaCoCoAllTestsSensor(JacocoConfiguration configuration) {
+ public JaCoCoOverallSensor(JacocoConfiguration configuration) {
this.configuration = configuration;
}
@@ -59,14 +59,14 @@ public class JaCoCoAllTestsSensor implements Sensor {
public void analyse(Project project, SensorContext context) {
mergeReports(project);
- new AllTestsAnalyzer().analyse(project, context);
+ new OverallAnalyzer().analyse(project, context);
}
private void mergeReports(Project project) {
File reportUTs = project.getFileSystem().resolvePath(configuration.getReportPath());
File reportITs = project.getFileSystem().resolvePath(configuration.getItReportPath());
- File reportAllTests = project.getFileSystem().resolvePath(MERGED_EXEC);
- reportAllTests.getParentFile().mkdirs();
+ File reportOverall = project.getFileSystem().resolvePath(JACOCO_OVERALL);
+ reportOverall.getParentFile().mkdirs();
SessionInfoStore infoStore = new SessionInfoStore();
ExecutionDataStore dataStore = new ExecutionDataStore();
@@ -75,13 +75,13 @@ public class JaCoCoAllTestsSensor implements Sensor {
BufferedOutputStream outputStream = null;
try {
- outputStream = new BufferedOutputStream(new FileOutputStream(reportAllTests));
+ outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall));
ExecutionDataWriter dataWriter = new ExecutionDataWriter(outputStream);
infoStore.accept(dataWriter);
dataStore.accept(dataWriter);
} catch (IOException e) {
- throw new SonarException(String.format("Unable to write merged file %s", reportAllTests.getAbsolutePath()), e);
+ throw new SonarException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e);
} finally {
Closeables.closeQuietly(outputStream);
}
@@ -104,10 +104,10 @@ public class JaCoCoAllTestsSensor implements Sensor {
}
}
- class AllTestsAnalyzer extends AbstractAnalyzer {
+ class OverallAnalyzer extends AbstractAnalyzer {
@Override
protected String getReportPath(Project project) {
- return MERGED_EXEC;
+ return JACOCO_OVERALL;
}
@Override
@@ -127,19 +127,19 @@ public class JaCoCoAllTestsSensor implements Sensor {
private Measure convertForAllTests(Measure measure) {
if (CoreMetrics.LINES_TO_COVER.equals(measure.getMetric())) {
- return new Measure(CoreMetrics.MERGED_LINES_TO_COVER, measure.getValue());
+ return new Measure(CoreMetrics.OVERALL_LINES_TO_COVER, measure.getValue());
} else if (CoreMetrics.UNCOVERED_LINES.equals(measure.getMetric())) {
- return new Measure(CoreMetrics.MERGED_UNCOVERED_LINES, measure.getValue());
+ return new Measure(CoreMetrics.OVERALL_UNCOVERED_LINES, measure.getValue());
} else if (CoreMetrics.COVERAGE_LINE_HITS_DATA.equals(measure.getMetric())) {
- return new Measure(CoreMetrics.MERGED_COVERAGE_LINE_HITS_DATA, measure.getData());
+ return new Measure(CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA, measure.getData());
} else if (CoreMetrics.CONDITIONS_TO_COVER.equals(measure.getMetric())) {
- return new Measure(CoreMetrics.MERGED_CONDITIONS_TO_COVER, measure.getValue());
+ return new Measure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER, measure.getValue());
} else if (CoreMetrics.UNCOVERED_CONDITIONS.equals(measure.getMetric())) {
- return new Measure(CoreMetrics.MERGED_UNCOVERED_CONDITIONS, measure.getValue());
+ return new Measure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, measure.getValue());
} else if (CoreMetrics.COVERED_CONDITIONS_BY_LINE.equals(measure.getMetric())) {
- return new Measure(CoreMetrics.MERGED_COVERED_CONDITIONS_BY_LINE, measure.getData());
+ return new Measure(CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE, measure.getData());
} else if (CoreMetrics.CONDITIONS_BY_LINE.equals(measure.getMetric())) {
- return new Measure(CoreMetrics.MERGED_CONDITIONS_BY_LINE, measure.getData());
+ return new Measure(CoreMetrics.OVERALL_CONDITIONS_BY_LINE, measure.getData());
}
return null;
}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
index 9a6a2016982..d6150513661 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
@@ -40,6 +40,6 @@ public class JaCoCoPlugin extends SonarPlugin {
JaCoCoSensor.class,
// Integration tests
JaCoCoItSensor.class,
- JaCoCoAllTestsSensor.class);
+ JaCoCoOverallSensor.class);
}
}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java
index bc318e66b6f..98d63538619 100644
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest.java
+++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java
@@ -40,12 +40,12 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
-public class JaCoCoAllTestsSensorTest {
+public class JaCoCoOverallSensorTest {
private final JacocoConfiguration configuration= mock(JacocoConfiguration.class);
private final SensorContext context = mock(SensorContext.class);
private final ProjectFileSystem pfs = mock(ProjectFileSystem.class);
private final Project project = mock(Project.class);
- private final JaCoCoAllTestsSensor sensor = new JaCoCoAllTestsSensor(configuration);
+ private final JaCoCoOverallSensor sensor = new JaCoCoOverallSensor(configuration);
@Test
public void should_execute_on_project() {
@@ -66,7 +66,7 @@ public class JaCoCoAllTestsSensorTest {
@Test
public void should_save_measures() throws IOException {
- File outputDir = TestUtils.getResource(JaCoCoAllTestsSensorTest.class, ".");
+ File outputDir = TestUtils.getResource(JaCoCoOverallSensorTest.class, ".");
Files.copy(TestUtils.getResource("HelloWorld.class.toCopy"), new File(outputDir, "HelloWorld.class"));
JavaFile resource = new JavaFile("com.sonar.coverages.HelloWorld");
@@ -78,19 +78,19 @@ public class JaCoCoAllTestsSensorTest {
when(pfs.getBuildOutputDir()).thenReturn(outputDir);
when(pfs.resolvePath("ut.exec")).thenReturn(new File(outputDir, "ut.exec"));
when(pfs.resolvePath("it.exec")).thenReturn(new File(outputDir, "it.exec"));
- when(pfs.resolvePath("target/sonar/merged.exec")).thenReturn(new File("target/sonar/merged.exec"));
+ when(pfs.resolvePath("target/sonar/jacoco-overall.exec")).thenReturn(new File("target/sonar/jacoco-overall.exec"));
sensor.analyse(project, context);
verify(context).getResource(resource);
- verify(context).saveMeasure(resource, new Measure(CoreMetrics.MERGED_LINES_TO_COVER, 5.0));
- verify(context).saveMeasure(resource, new Measure(CoreMetrics.MERGED_UNCOVERED_LINES, 0.0));
- verify(context).saveMeasure(resource, new Measure(CoreMetrics.MERGED_COVERAGE_LINE_HITS_DATA, "3=1;6=1;7=1;10=1;11=1"));
+ verify(context).saveMeasure(resource, new Measure(CoreMetrics.OVERALL_LINES_TO_COVER, 5.0));
+ verify(context).saveMeasure(resource, new Measure(CoreMetrics.OVERALL_UNCOVERED_LINES, 0.0));
+ verify(context).saveMeasure(resource, new Measure(CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA, "3=1;6=1;7=1;10=1;11=1"));
verifyNoMoreInteractions(context);
}
@Test
public void testSensorDefinition() {
- assertThat(sensor.toString()).isEqualTo("JaCoCoAllTestsSensor");
+ assertThat(sensor.toString()).isEqualTo("JaCoCoOverallSensor");
}
}
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest/it.exec b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec
index ce2421df376..ce2421df376 100644
--- a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest/it.exec
+++ b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec
Binary files differ
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest/ut.exec b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec
index 09d84373641..09d84373641 100644
--- a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoAllTestsSensorTest/ut.exec
+++ b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec
Binary files differ