Search in sources :

Example 1 with CoverageBlock

use of org.sonar.api.test.CoverageBlock in project sonarqube by SonarSource.

the class TestExecutionAndCoveragePublisher method toProtobufCoverageDetails.

private CoverageDetail toProtobufCoverageDetails(final ScannerReport.CoverageDetail.Builder builder, final ScannerReport.CoverageDetail.CoveredFile.Builder coveredBuilder, final MutableTestPlan testPlan, String testName) {
    // Take first test with provided name
    MutableTestCase testCase = testPlan.testCasesByName(testName).iterator().next();
    builder.clear();
    builder.setTestName(testName);
    for (CoverageBlock block : testCase.coverageBlocks()) {
        coveredBuilder.clear();
        DefaultInputComponent c = (DefaultInputComponent) componentStore.getByKey(((DefaultTestable) block.testable()).inputFile().key());
        coveredBuilder.setFileRef(c.batchId());
        for (int line : block.lines()) {
            coveredBuilder.addCoveredLine(line);
        }
        builder.addCoveredFile(coveredBuilder.build());
    }
    return builder.build();
}
Also used : MutableTestCase(org.sonar.api.test.MutableTestCase) CoverageBlock(org.sonar.api.test.CoverageBlock) DefaultInputComponent(org.sonar.api.batch.fs.internal.DefaultInputComponent)

Aggregations

DefaultInputComponent (org.sonar.api.batch.fs.internal.DefaultInputComponent)1 CoverageBlock (org.sonar.api.test.CoverageBlock)1 MutableTestCase (org.sonar.api.test.MutableTestCase)1