use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class GenericTestExecutionMediumTest method twoReports.
@Test
public void twoReports() {
File projectDir = new File("test-resources/mediumtest/xoo/sample-generic-test-exec");
AnalysisResult result = tester.setLogOutput((msg, level) -> logs.add(msg)).newAnalysis(new File(projectDir, "sonar-project.properties")).property("sonar.testExecutionReportPaths", "unittest.xml,unittest2.xml").execute();
InputFile testFile = result.inputFile("testx/ClassOneTest.xoo");
assertThat(result.allMeasures().get(testFile.key())).extracting("metricKey", "intValue.value", "longValue.value").containsOnly(tuple(CoreMetrics.TESTS_KEY, 4, 0L), tuple(CoreMetrics.SKIPPED_TESTS_KEY, 2, 0L), tuple(CoreMetrics.TEST_ERRORS_KEY, 1, 0L), tuple(CoreMetrics.TEST_EXECUTION_TIME_KEY, 0, 1610L), tuple(CoreMetrics.TEST_FAILURES_KEY, 1, 0L));
assertThat(logs).noneMatch(l -> l.contains("Please use 'sonar.testExecutionReportPaths'"));
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class CpdMediumTest method testFilesWithoutBlocks.
@Test
public void testFilesWithoutBlocks() throws IOException {
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
String file1 = "Sample xoo\ncontent\n" + "foo\nbar\ntoto\ntiti\n" + "foo\nbar\ntoto\ntiti\n" + "bar\ntoto\ntiti\n" + "foo\nbar\ntoto\ntiti";
String file2 = "string\n";
File xooFile1 = new File(srcDir, "sample1.xoo");
FileUtils.write(xooFile1, file1, StandardCharsets.UTF_8);
File xooFile2 = new File(srcDir, "sample2.xoo");
FileUtils.write(xooFile2, file2, StandardCharsets.UTF_8);
AnalysisResult result = tester.newAnalysis().properties(builder.put("sonar.sources", "src").put("sonar.cpd.xoo.minimumTokens", "10").put("sonar.verbose", "true").build()).execute();
assertThat(result.inputFiles()).hasSize(2);
assertThat(logTester.logs()).contains("Not enough content in 'src/sample2.xoo' to have CPD blocks, it will not be part of the duplication detection");
assertThat(logTester.logs()).contains("CPD Executor 1 file had no CPD blocks");
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method scanProjectWithWrongCase.
// SONAR-6719
@Test
public void scanProjectWithWrongCase() {
// To please the quality gate, don't use assumeTrue, or the test will be reported as skipped
File projectDir = new File("test-resources/mediumtest/xoo/sample");
AnalysisBuilder analysis = tester.newAnalysis(new File(projectDir, "sonar-project.properties")).property("sonar.sources", "XOURCES").property("sonar.tests", "TESTX").property("sonar.scm.exclusions.disabled", "true");
if (System2.INSTANCE.isOsWindows()) {
// Windows is file path case-insensitive
AnalysisResult result = analysis.execute();
assertThat(result.inputFiles()).hasSize(8);
assertThat(result.inputFiles()).extractingResultOf("relativePath").containsOnly("testx/ClassOneTest.xoo.measures", "xources/hello/helloscala.xoo.measures", "xources/hello/HelloJava.xoo.measures", "testx/ClassOneTest.xoo", "xources/hello/HelloJava.xoo.scm", "xources/hello/helloscala.xoo", "testx/ClassOneTest.xoo.scm", "xources/hello/HelloJava.xoo");
} else if (System2.INSTANCE.isOsMac()) {
AnalysisResult result = analysis.execute();
assertThat(result.inputFiles()).hasSize(8);
assertThat(result.inputFiles()).extractingResultOf("relativePath").containsOnly("TESTX/ClassOneTest.xoo.measures", "XOURCES/hello/helloscala.xoo.measures", "XOURCES/hello/HelloJava.xoo.measures", "TESTX/ClassOneTest.xoo", "XOURCES/hello/HelloJava.xoo.scm", "XOURCES/hello/helloscala.xoo", "TESTX/ClassOneTest.xoo.scm", "XOURCES/hello/HelloJava.xoo");
} else {
assertThatThrownBy(() -> analysis.execute()).isInstanceOf(MessageException.class).hasMessageContaining("The folder 'TESTX' does not exist for 'sample'");
}
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method index_basedir_by_default.
@Test
public void index_basedir_by_default() throws IOException {
writeFile(baseDir, "sample.xoo", "Sample xoo\ncontent");
AnalysisResult result = tester.newAnalysis().properties(builder.build()).execute();
assertThat(logTester.logs()).contains("1 file indexed");
assertThat(result.inputFile("sample.xoo")).isNotNull();
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method scanMultiModuleProject.
@Test
public void scanMultiModuleProject() {
File projectDir = new File("test-resources/mediumtest/xoo/multi-modules-sample");
AnalysisResult result = tester.newAnalysis(new File(projectDir, "sonar-project.properties")).execute();
assertThat(result.inputFiles()).hasSize(4);
}
Aggregations