diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-21 01:47:18 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-21 01:48:34 +0400 |
commit | ec2974edf37405ed45328dd5885409dfc861ca63 (patch) | |
tree | 735160968285b7813bd2f66004b5aac21dc0b861 /plugins/sonar-surefire-plugin | |
parent | 986b9dfe5b578402b3ecdb7ccde5abc5fe06f7da (diff) | |
download | sonarqube-ec2974edf37405ed45328dd5885409dfc861ca63.tar.gz sonarqube-ec2974edf37405ed45328dd5885409dfc861ca63.zip |
SONAR-2341 Deprecate Project.getPackaging and don't use it in findbugs plugin
Diffstat (limited to 'plugins/sonar-surefire-plugin')
-rw-r--r-- | plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java index 15b007f9018..690603fc091 100644 --- a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java +++ b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefireSensorTest.java @@ -73,7 +73,6 @@ public class SurefireSensorTest { new SurefireSensor().collect(project, mock(SensorContext.class), new File("unknown")); } - private SensorContext mockContext() { SensorContext context = mock(SensorContext.class); when(context.isIndexed(any(Resource.class), eq(false))).thenReturn(true); @@ -83,17 +82,17 @@ public class SurefireSensorTest { @Test public void shouldHandleTestSuiteDetails() throws URISyntaxException { SensorContext context = mockContext(); - new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource( + new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource( "/org/sonar/plugins/surefire/SurefireSensorTest/shouldHandleTestSuiteDetails/").toURI())); // 3 classes, 6 measures by class - verify(context, times(3)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(3)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), eq(CoreMetrics.SKIPPED_TESTS), anyDouble()); - verify(context, times(3)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(3)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), eq(CoreMetrics.TESTS), anyDouble()); - verify(context, times(18)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(18)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), (Metric) anyObject(), anyDouble()); - verify(context, times(3)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(3)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), argThat(new IsMeasure(CoreMetrics.TEST_DATA))); verify(context).saveMeasure(eq(new JavaFile("org.sonar.core.ExtensionsFinderTest", true)), eq(CoreMetrics.TESTS), eq(4d)); @@ -127,18 +126,18 @@ public class SurefireSensorTest { @Test public void shouldSaveErrorsAndFailuresInXML() throws URISyntaxException { SensorContext context = mockContext(); - new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource( + new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource( "/org/sonar/plugins/surefire/SurefireSensorTest/shouldSaveErrorsAndFailuresInXML/").toURI())); // 1 classes, 6 measures by class - verify(context, times(1)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(1)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), eq(CoreMetrics.SKIPPED_TESTS), anyDouble()); - verify(context, times(1)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(1)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), eq(CoreMetrics.TESTS), anyDouble()); - verify(context, times(6)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(6)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), (Metric) anyObject(), anyDouble()); - verify(context, times(1)).saveMeasure(argThat(new IsResource(JavaFile.SCOPE_ENTITY, Qualifiers.UNIT_TEST_FILE)), + verify(context, times(1)).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.UNIT_TEST_FILE)), argThat(new IsMeasure(CoreMetrics.TEST_DATA))); verify(context).saveMeasure(eq(new JavaFile("org.sonar.core.ExtensionsFinderTest", true)), @@ -148,7 +147,7 @@ public class SurefireSensorTest { @Test public void shouldManageClassesWithDefaultPackage() throws URISyntaxException { SensorContext context = mockContext(); - new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource( + new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource( "/org/sonar/plugins/surefire/SurefireSensorTest/shouldManageClassesWithDefaultPackage/").toURI())); verify(context).saveMeasure(new JavaFile("NoPackagesTest", true), CoreMetrics.TESTS, 2d); @@ -157,7 +156,7 @@ public class SurefireSensorTest { @Test public void successRatioIsZeroWhenAllTestsFail() throws URISyntaxException { SensorContext context = mockContext(); - new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource( + new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource( "/org/sonar/plugins/surefire/SurefireSensorTest/successRatioIsZeroWhenAllTestsFail/").toURI())); verify(context).saveMeasure(eq(new JavaFile("org.sonar.Foo", true)), eq(CoreMetrics.TESTS), eq(2d)); @@ -169,7 +168,7 @@ public class SurefireSensorTest { @Test public void measuresShouldNotIncludeSkippedTests() throws URISyntaxException { SensorContext context = mockContext(); - new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource( + new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource( "/org/sonar/plugins/surefire/SurefireSensorTest/measuresShouldNotIncludeSkippedTests/").toURI())); verify(context).saveMeasure(eq(new JavaFile("org.sonar.Foo", true)), eq(CoreMetrics.TESTS), eq(2d)); @@ -182,7 +181,7 @@ public class SurefireSensorTest { @Test public void noSuccessRatioIfNoTests() throws URISyntaxException { SensorContext context = mockContext(); - new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource( + new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource( "/org/sonar/plugins/surefire/SurefireSensorTest/noSuccessRatioIfNoTests/").toURI())); verify(context).saveMeasure(eq(new JavaFile("org.sonar.Foo", true)), eq(CoreMetrics.TESTS), eq(0d)); @@ -195,7 +194,7 @@ public class SurefireSensorTest { @Test public void ignoreSuiteAsInnerClass() throws URISyntaxException { SensorContext context = mockContext(); - new SurefireSensor().collect(newJarProject(), context, new File(getClass().getResource( + new SurefireSensor().collect(new Project("key"), context, new File(getClass().getResource( "/org/sonar/plugins/surefire/SurefireSensorTest/ignoreSuiteAsInnerClass/").toURI())); // ignore TestHandler$Input.xml @@ -232,12 +231,4 @@ public class SurefireSensorTest { } }; } - - private static Project newJarProject() { - return new Project("key").setPackaging("jar"); - } - - private static Project newPomProject() { - return new Project("key").setPackaging("pom"); - } } |