Search in sources :

Example 31 with TestInputFileBuilder

use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.

the class OverallCoverageSensorTest 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);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 32 with TestInputFileBuilder

use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.

the class OverallCoverageSensorTest method testLineHitAndConditions.

@Test
public void testLineHitAndConditions() throws IOException {
    File coverage = new File(baseDir, "src/foo.xoo.overallcoverage");
    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);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 33 with TestInputFileBuilder

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);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 34 with TestInputFileBuilder

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);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 35 with TestInputFileBuilder

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);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Aggregations

TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)87 Test (org.junit.Test)77 InputFile (org.sonar.api.batch.fs.InputFile)41 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)23 File (java.io.File)19 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)9 Before (org.junit.Before)7 DefaultInputDir (org.sonar.api.batch.fs.internal.DefaultInputDir)6 InputModuleHierarchy (org.sonar.api.batch.fs.internal.InputModuleHierarchy)5 BlameLine (org.sonar.api.batch.scm.BlameLine)5 AnalysisMode (org.sonar.api.batch.AnalysisMode)4 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)4 SensorContextTester (org.sonar.api.batch.sensor.internal.SensorContextTester)4 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)4 Issue (org.sonar.api.batch.sensor.issue.Issue)4 PathResolver (org.sonar.api.scan.filesystem.PathResolver)4 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)4 DefaultBlameOutput (org.sonar.scanner.scm.DefaultBlameOutput)4 DefaultTextPointer (org.sonar.api.batch.fs.internal.DefaultTextPointer)3 DefaultSensorDescriptor (org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor)3