diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-19 19:33:47 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-20 01:41:21 +0400 |
commit | 060c18523247bd07431ba5de664193247afa7b9a (patch) | |
tree | f21fbef3885ea97d64939454a7fb3420ab444270 /plugins/sonar-surefire-plugin | |
parent | 5cc143c7351b3a5d8334a59b42720407232f4153 (diff) | |
download | sonarqube-060c18523247bd07431ba5de664193247afa7b9a.tar.gz sonarqube-060c18523247bd07431ba5de664193247afa7b9a.zip |
SONAR-2371 SurefireSensor should not insert unit test measures when there is no reports
- UnitTestDecorator should save zero for unit test measure for project, when there is
no values for summarizing and type of analysis is reuse reports or dynamic
- Don't use pom.getPackaging() in AbstractSurefireParser
Diffstat (limited to 'plugins/sonar-surefire-plugin')
2 files changed, 4 insertions, 14 deletions
diff --git a/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/api/AbstractSurefireParser.java b/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/api/AbstractSurefireParser.java index c8d6a5fd372..d0cc6262093 100644 --- a/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/api/AbstractSurefireParser.java +++ b/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/api/AbstractSurefireParser.java @@ -33,11 +33,12 @@ import org.sonar.plugins.surefire.data.SurefireStaxHandler; import org.sonar.plugins.surefire.data.UnitTestClassReport; import org.sonar.plugins.surefire.data.UnitTestIndex; -import javax.xml.stream.XMLStreamException; import java.io.File; import java.io.FilenameFilter; import java.util.Map; +import javax.xml.stream.XMLStreamException; + /** * @since 2.4 */ @@ -46,9 +47,7 @@ public abstract class AbstractSurefireParser { public void collect(Project project, SensorContext context, File reportsDir) { File[] xmlFiles = getReports(reportsDir); - if (xmlFiles.length == 0) { - insertZeroWhenNoReports(project, context); - } else { + if (xmlFiles.length != 0) { parseFiles(context, xmlFiles); } } @@ -64,18 +63,11 @@ public abstract class AbstractSurefireParser { }); } - private void insertZeroWhenNoReports(Project project, SensorContext context) { - if (!StringUtils.equalsIgnoreCase("pom", project.getPackaging())) { - context.saveMeasure(CoreMetrics.TESTS, 0.0); - } - } - private void parseFiles(SensorContext context, File[] reports) { UnitTestIndex index = new UnitTestIndex(); parseFiles(reports, index); sanitize(index); save(index, context); - } private void parseFiles(File[] reports, UnitTestIndex index) { @@ -121,7 +113,6 @@ public abstract class AbstractSurefireParser { } } - private void saveMeasure(SensorContext context, Resource resource, Metric metric, double value) { if (!Double.isNaN(value)) { context.saveMeasure(resource, metric, value); diff --git a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/api/AbstractSurefireParserTest.java b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/api/AbstractSurefireParserTest.java index 697c94a5750..15085fee0c4 100644 --- a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/api/AbstractSurefireParserTest.java +++ b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/api/AbstractSurefireParserTest.java @@ -22,7 +22,6 @@ package org.sonar.plugins.surefire.api; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Test; -import org.mockito.internal.matchers.StartsWith; import org.sonar.api.batch.SensorContext; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; @@ -60,7 +59,7 @@ public class AbstractSurefireParserTest { parser.collect(new Project("foo"), context, getDir("noReports")); - verify(context).saveMeasure(CoreMetrics.TESTS, 0.0); + verifyZeroInteractions(context); } @Test |