use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class GenericTestExecutionMediumTest method twoReports.
@Test
public void twoReports() throws IOException {
File projectDir = new File("src/test/resources/mediumtest/xoo/sample-generic-test-exec");
TaskResult result = tester.newScanTask(new File(projectDir, "sonar-project.properties")).property("sonar.testExecutionReportPaths", "unittest.xml,unittest2.xml").start();
InputFile testFile = result.inputFile("testx/ClassOneTest.xoo");
ScannerReport.Test success = result.firstTestExecutionForName(testFile, "test1");
assertThat(success.getDurationInMs()).isEqualTo(5);
assertThat(success.getStatus()).isEqualTo(TestStatus.OK);
ScannerReport.Test success2 = result.firstTestExecutionForName(testFile, "test1b");
assertThat(success2.getDurationInMs()).isEqualTo(5);
assertThat(success2.getStatus()).isEqualTo(TestStatus.OK);
ScannerReport.Test skipped = result.firstTestExecutionForName(testFile, "test2");
assertThat(skipped.getDurationInMs()).isEqualTo(500);
assertThat(skipped.getStatus()).isEqualTo(TestStatus.SKIPPED);
assertThat(skipped.getMsg()).isEqualTo("short message");
assertThat(skipped.getStacktrace()).isEqualTo("other");
ScannerReport.Test failed = result.firstTestExecutionForName(testFile, "test3");
assertThat(failed.getDurationInMs()).isEqualTo(100);
assertThat(failed.getStatus()).isEqualTo(TestStatus.FAILURE);
assertThat(failed.getMsg()).isEqualTo("short");
assertThat(failed.getStacktrace()).isEqualTo("stacktrace");
ScannerReport.Test error = result.firstTestExecutionForName(testFile, "test4");
assertThat(error.getDurationInMs()).isEqualTo(500);
assertThat(error.getStatus()).isEqualTo(TestStatus.ERROR);
assertThat(error.getMsg()).isEqualTo("short");
assertThat(error.getStacktrace()).isEqualTo("stacktrace");
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));
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class DefaultBlameOutputTest method shouldFailIfNotExpectedFile.
@Test
public void shouldFailIfNotExpectedFile() {
InputFile file = new TestInputFileBuilder("foo", "src/main/java/Foo.java").build();
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("It was not expected to blame file src/main/java/Foo.java");
new DefaultBlameOutput(null, Arrays.<InputFile>asList(new TestInputFileBuilder("foo", "src/main/java/Foo2.java").build())).blameResult(file, Arrays.asList(new BlameLine().revision("1").author("guy")));
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class DefaultBlameOutputTest method shouldFailIfNullDate.
@Test
public void shouldFailIfNullDate() {
InputFile file = new TestInputFileBuilder("foo", "src/main/java/Foo.java").setLines(1).build();
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Blame date is null for file src/main/java/Foo.java at line 1");
new DefaultBlameOutput(null, Arrays.<InputFile>asList(file)).blameResult(file, Arrays.asList(new BlameLine().revision("1").author("guy")));
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method duplicateHighlighting.
@Test(expected = UnsupportedOperationException.class)
public void duplicateHighlighting() throws Exception {
InputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.java").setModuleBaseDir(temp.newFolder().toPath()).build();
DefaultHighlighting h = new DefaultHighlighting(null).onFile(inputFile);
underTest.store(h);
underTest.store(h);
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method shouldValidateMaxLine.
@Test
public void shouldValidateMaxLine() throws Exception {
InputFile file = new TestInputFileBuilder("module", "testfile").setModuleBaseDir(temp.newFolder().toPath()).build();
Map<Integer, Integer> map = ImmutableMap.of(11, 3);
String data = KeyValueFormat.format(map);
thrown.expect(IllegalStateException.class);
underTest.validateCoverageMeasure(data, file);
}
Aggregations