Search in sources :

Example 1 with DefaultConfiguration

use of org.sonar.scanner.config.DefaultConfiguration in project sonarqube by SonarSource.

the class GenericCoverageSensorTest method loadAllReportPaths.

@Test
public void loadAllReportPaths() {
    Map<String, String> settings = new HashMap<>();
    settings.put(GenericCoverageSensor.REPORT_PATHS_PROPERTY_KEY, "report.xml,report2.xml");
    PropertyDefinitions defs = new PropertyDefinitions(System2.INSTANCE, GenericCoverageSensor.properties());
    DefaultConfiguration config = new ProjectConfiguration(defs, new Encryption(null), settings);
    Set<String> reportPaths = new GenericCoverageSensor(config).loadReportPaths();
    assertThat(reportPaths).containsOnly("report.xml", "report2.xml");
}
Also used : PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) HashMap(java.util.HashMap) DefaultConfiguration(org.sonar.scanner.config.DefaultConfiguration) Encryption(org.sonar.api.config.internal.Encryption) ProjectConfiguration(org.sonar.scanner.scan.ProjectConfiguration) Test(org.junit.Test)

Example 2 with DefaultConfiguration

use of org.sonar.scanner.config.DefaultConfiguration in project sonarqube by SonarSource.

the class GenericTestExecutionSensorTest method logWhenDeprecatedPropsAreUsed.

@Test
public void logWhenDeprecatedPropsAreUsed() throws IOException {
    File basedir = temp.newFolder();
    File report = new File(basedir, "report.xml");
    FileUtils.write(report, "<unitTest version=\"1\"><file path=\"A.java\"><testCase name=\"test1\" duration=\"500\"/></file></unitTest>", StandardCharsets.UTF_8);
    SensorContextTester context = SensorContextTester.create(basedir);
    Map<String, String> settings = new HashMap<>();
    settings.put(GenericTestExecutionSensor.OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY, "report.xml");
    PropertyDefinitions defs = new PropertyDefinitions(System2.INSTANCE, GenericTestExecutionSensor.properties());
    DefaultConfiguration config = new ProjectConfiguration(defs, new Encryption(null), settings);
    new GenericTestExecutionSensor(mock(TestPlanBuilder.class), config).execute(context);
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Using 'unitTest' as root element of the report is deprecated. Please change to 'testExecutions'.", "Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead.");
    assertThat(logTester.logs(LoggerLevel.INFO)).contains("Imported test execution data for 0 files", "Test execution data ignored for 1 unknown files, including:\nA.java");
}
Also used : SensorContextTester(org.sonar.api.batch.sensor.internal.SensorContextTester) PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) HashMap(java.util.HashMap) DefaultConfiguration(org.sonar.scanner.config.DefaultConfiguration) Encryption(org.sonar.api.config.internal.Encryption) File(java.io.File) ProjectConfiguration(org.sonar.scanner.scan.ProjectConfiguration) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 Test (org.junit.Test)2 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)2 Encryption (org.sonar.api.config.internal.Encryption)2 DefaultConfiguration (org.sonar.scanner.config.DefaultConfiguration)2 ProjectConfiguration (org.sonar.scanner.scan.ProjectConfiguration)2 File (java.io.File)1 SensorContextTester (org.sonar.api.batch.sensor.internal.SensorContextTester)1