Search in sources :

Example 1 with Testable

use of org.sonar.api.test.Testable in project sonar-java by SonarSource.

the class UnitTestAnalyzer method addCoverage.

private boolean addCoverage(InputFile resource, InputFile testFile, String testName, List<Integer> coveredLines) {
    boolean result = false;
    Testable testAbleFile = perspectives.as(MutableTestable.class, resource);
    if (testAbleFile != null) {
        MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, testFile);
        if (testPlan != null) {
            for (MutableTestCase testCase : testPlan.testCasesByName(testName)) {
                testCase.setCoverageBlock(testAbleFile, coveredLines);
                result = true;
            }
        }
    }
    return result;
}
Also used : MutableTestPlan(org.sonar.api.test.MutableTestPlan) MutableTestCase(org.sonar.api.test.MutableTestCase) Testable(org.sonar.api.test.Testable) MutableTestable(org.sonar.api.test.MutableTestable)

Aggregations

MutableTestCase (org.sonar.api.test.MutableTestCase)1 MutableTestPlan (org.sonar.api.test.MutableTestPlan)1 MutableTestable (org.sonar.api.test.MutableTestable)1 Testable (org.sonar.api.test.Testable)1