use of org.sonar.api.batch.sensor.internal.SensorContextTester in project sonar-java by SonarSource.
the class SurefireSensorTest method should_support_reportNameSuffix.
@Test
void should_support_reportNameSuffix() throws URISyntaxException {
SensorContextTester context = SensorContextTester.create(new File(""));
context.fileSystem().add(resource("org.sonar.Foo"));
collect(context, "/org/sonar/plugins/surefire/SurefireSensorTest/should_support_reportNameSuffix/");
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TESTS).value()).isEqualTo(4);
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TEST_FAILURES).value()).isEqualTo(2);
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TEST_ERRORS).value()).isZero();
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.SKIPPED_TESTS).value()).isEqualTo(2);
}
use of org.sonar.api.batch.sensor.internal.SensorContextTester in project sonar-java by SonarSource.
the class SurefireSensorTest method noSuccessRatioIfNoTests.
@Test
void noSuccessRatioIfNoTests() throws URISyntaxException {
SensorContextTester context = SensorContextTester.create(new File(""));
context.fileSystem().add(resource("org.sonar.Foo"));
collect(context, "/org/sonar/plugins/surefire/SurefireSensorTest/noSuccessRatioIfNoTests/");
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TESTS).value()).isZero();
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TEST_FAILURES).value()).isZero();
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TEST_ERRORS).value()).isZero();
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.SKIPPED_TESTS).value()).isEqualTo(2);
}
use of org.sonar.api.batch.sensor.internal.SensorContextTester in project sonar-java by SonarSource.
the class SurefireSensorTest method measuresShouldNotIncludeSkippedTests.
@Test
void measuresShouldNotIncludeSkippedTests() throws URISyntaxException {
SensorContextTester context = SensorContextTester.create(new File(""));
context.fileSystem().add(resource("org.sonar.Foo"));
collect(context, "/org/sonar/plugins/surefire/SurefireSensorTest/measuresShouldNotIncludeSkippedTests/");
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TESTS).value()).isEqualTo(2);
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TEST_FAILURES).value()).isEqualTo(1);
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.TEST_ERRORS).value()).isZero();
assertThat(context.measure(":org.sonar.Foo", CoreMetrics.SKIPPED_TESTS).value()).isEqualTo(1);
}
use of org.sonar.api.batch.sensor.internal.SensorContextTester in project sonar-java by SonarSource.
the class DroppedPropertiesSensorTest method test_two_reportPaths_property_plus_another.
@Test
void test_two_reportPaths_property_plus_another() throws Exception {
SensorContextTester contextTester = SensorContextTester.create(tmp.newFolder());
MapSettings mapSettings = new MapSettings().setProperty("sonar.jacoco.reportPaths", "/path").setProperty("sonar.jacoco.reportPath", "/path").setProperty("sonar.jacoco.itReportPath", "/path");
contextTester.setSettings(mapSettings);
List<String> analysisWarnings = new ArrayList<>();
DroppedPropertiesSensor sensor = new DroppedPropertiesSensor(analysisWarnings::add);
sensor.execute(contextTester);
String msg = "Property 'sonar.jacoco.itReportPath' is no longer supported. Use JaCoCo's xml report and sonar-jacoco plugin.";
assertThat(logTester.logs(LoggerLevel.WARN)).contains(msg);
assertThat(analysisWarnings).containsExactly(msg);
}
use of org.sonar.api.batch.sensor.internal.SensorContextTester in project sonar-java by SonarSource.
the class DroppedPropertiesSensorTest method test.
@Test
void test() throws Exception {
SensorContextTester contextTester = SensorContextTester.create(tmp.newFolder());
MapSettings mapSettings = new MapSettings().setProperty("sonar.jacoco.reportPaths", "/path");
contextTester.setSettings(mapSettings);
List<String> analysisWarnings = new ArrayList<>();
DroppedPropertiesSensor sensor = new DroppedPropertiesSensor(analysisWarnings::add);
sensor.execute(contextTester);
String msg = "Property 'sonar.jacoco.reportPaths' is no longer supported. Use JaCoCo's xml report and sonar-jacoco plugin.";
assertThat(logTester.logs(LoggerLevel.WARN)).contains(msg);
assertThat(analysisWarnings).containsExactly(msg);
}
Aggregations