Search in sources :

Example 1 with FileCoverageBuilder

use of com.teamscale.report.testwise.model.builder.FileCoverageBuilder in project teamscale-jacoco-agent by cqse.

the class CoverageToTeamscaleStrategyTest method getDummyTestwiseCoverage.

/**
 * Returns a dummy testwise coverage object for a test with the given name that covers a few lines of Main.java.
 */
protected static TestwiseCoverage getDummyTestwiseCoverage(String test) {
    TestCoverageBuilder testCoverageBuilder = new TestCoverageBuilder(test);
    FileCoverageBuilder fileCoverageBuilder = new FileCoverageBuilder("src/main/java", "Main.java");
    fileCoverageBuilder.addLineRange(1, 4);
    testCoverageBuilder.add(fileCoverageBuilder);
    TestwiseCoverage testwiseCoverage = new TestwiseCoverage();
    testwiseCoverage.add(testCoverageBuilder);
    return testwiseCoverage;
}
Also used : TestwiseCoverage(com.teamscale.report.testwise.model.TestwiseCoverage) TestCoverageBuilder(com.teamscale.report.testwise.model.builder.TestCoverageBuilder) FileCoverageBuilder(com.teamscale.report.testwise.model.builder.FileCoverageBuilder)

Example 2 with FileCoverageBuilder

use of com.teamscale.report.testwise.model.builder.FileCoverageBuilder in project teamscale-jacoco-agent by cqse.

the class ClassCoverageLookup method getFileCoverage.

/**
 * Generates {@link FileCoverageBuilder} from an {@link ExecutionData}. {@link ExecutionData} holds coverage of
 * exactly one class (whereby inner classes are a separate class). This method returns a {@link FileCoverageBuilder}
 * object which is later merged with the {@link FileCoverageBuilder} of other classes that reside in the same file.
 */
public FileCoverageBuilder getFileCoverage(ExecutionData executionData, ILogger logger) throws CoverageGenerationException {
    boolean[] executedProbes = executionData.getProbes();
    if (checkProbeInvariant(executedProbes)) {
        throw new CoverageGenerationException("Probe lookup does not match with actual probe size for " + sourceFileName + " " + className + " (" + probes.size() + " vs " + executedProbes.length + ")! " + "This is a bug in the profiler tooling. Please report it back to CQSE.");
    }
    if (sourceFileName == null) {
        logger.warn("No source file name found for class " + className + "! This class was probably not compiled with " + "debug information enabled!");
        return null;
    }
    // we model the default package as the empty string
    String packageName = "";
    if (className.contains("/")) {
        packageName = StringUtils.removeLastPart(className, '/');
    }
    final FileCoverageBuilder fileCoverage = new FileCoverageBuilder(packageName, sourceFileName);
    fillFileCoverage(fileCoverage, executedProbes, logger);
    return fileCoverage;
}
Also used : FileCoverageBuilder(com.teamscale.report.testwise.model.builder.FileCoverageBuilder)

Aggregations

FileCoverageBuilder (com.teamscale.report.testwise.model.builder.FileCoverageBuilder)2 TestwiseCoverage (com.teamscale.report.testwise.model.TestwiseCoverage)1 TestCoverageBuilder (com.teamscale.report.testwise.model.builder.TestCoverageBuilder)1