use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class UtCoverageSensorTest method testLineHitNoConditions.
@Test
public void testLineHitNoConditions() throws IOException {
File coverage = new File(baseDir, "src/foo.xoo.coverage");
FileUtils.write(coverage, "1:3\n\n#comment");
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).setLines(10).build();
context.fileSystem().add(inputFile);
sensor.execute(context);
assertThat(context.lineHits("foo:src/foo.xoo", 1)).isEqualTo(3);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class UtCoverageSensorTest method testLineHitAndConditions.
@Test
public void testLineHitAndConditions() throws IOException {
File coverage = new File(baseDir, "src/foo.xoo.coverage");
FileUtils.write(coverage, "1:3:4:2");
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).setLines(10).build();
context.fileSystem().add(inputFile);
sensor.execute(context);
assertThat(context.lineHits("foo:src/foo.xoo", 1)).isEqualTo(3);
assertThat(context.conditions("foo:src/foo.xoo", 1)).isEqualTo(4);
assertThat(context.coveredConditions("foo:src/foo.xoo", 1)).isEqualTo(2);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class UtCoverageSensorTest method testNoExecutionIfNoCoverageFile.
@Test
public void testNoExecutionIfNoCoverageFile() {
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
context.fileSystem().add(inputFile);
sensor.execute(context);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class MeasureSensorTest method testNoExecutionIfNoMeasureFile.
@Test
public void testNoExecutionIfNoMeasureFile() {
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").build();
context.fileSystem().add(inputFile);
sensor.execute(context);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class SensorContextTesterTest method testConditions.
@Test
public void testConditions() {
assertThat(tester.conditions("foo:src/Foo.java", 1)).isNull();
assertThat(tester.coveredConditions("foo:src/Foo.java", 1)).isNull();
tester.newCoverage().onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar\nasd\nasdas\nasdfas").build()).conditions(1, 4, 2).save();
assertThat(tester.conditions("foo:src/Foo.java", 1)).isEqualTo(4);
assertThat(tester.coveredConditions("foo:src/Foo.java", 1)).isEqualTo(2);
}
Aggregations