Search in sources :

Example 1 with JaCoCoTestwiseReportGenerator

use of com.teamscale.report.testwise.jacoco.JaCoCoTestwiseReportGenerator in project teamscale-jacoco-agent by cqse.

the class Converter method runTestwiseCoverageReportGeneration.

/**
 * Converts one .exec binary coverage file, test details and test execution files to JSON testwise coverage.
 */
public void runTestwiseCoverageReportGeneration() throws IOException, CoverageGenerationException, AgentOptionParseException {
    List<TestDetails> testDetails = ReportUtils.readObjects(ETestArtifactFormat.TEST_LIST, TestDetails[].class, arguments.getInputFiles());
    List<TestExecution> testExecutions = ReportUtils.readObjects(ETestArtifactFormat.TEST_EXECUTION, TestExecution[].class, arguments.getInputFiles());
    List<File> jacocoExecutionDataList = ReportUtils.listFiles(ETestArtifactFormat.JACOCO, arguments.getInputFiles());
    ILogger logger = new CommandLineLogger();
    JaCoCoTestwiseReportGenerator generator = new JaCoCoTestwiseReportGenerator(arguments.getClassDirectoriesOrZips(), getWildcardIncludeExcludeFilter(), arguments.getDuplicateClassFileBehavior(), logger);
    TestInfoFactory testInfoFactory = new TestInfoFactory(testDetails, testExecutions);
    try (Benchmark benchmark = new Benchmark("Generating the testwise coverage report")) {
        logger.info("Writing report with " + testDetails.size() + " Details/" + testExecutions.size() + " Results");
        try (TestwiseCoverageReportWriter coverageWriter = new TestwiseCoverageReportWriter(testInfoFactory, arguments.getOutputFile(), arguments.getSplitAfter())) {
            for (File executionDataFile : jacocoExecutionDataList) {
                generator.convertAndConsume(executionDataFile, coverageWriter);
            }
        }
    }
}
Also used : TestInfoFactory(com.teamscale.report.testwise.model.factory.TestInfoFactory) TestExecution(com.teamscale.report.testwise.model.TestExecution) Benchmark(com.teamscale.jacoco.agent.util.Benchmark) ILogger(com.teamscale.report.util.ILogger) TestDetails(com.teamscale.client.TestDetails) File(java.io.File) CommandLineLogger(com.teamscale.report.util.CommandLineLogger) TestwiseCoverageReportWriter(com.teamscale.report.testwise.TestwiseCoverageReportWriter) JaCoCoTestwiseReportGenerator(com.teamscale.report.testwise.jacoco.JaCoCoTestwiseReportGenerator)

Aggregations

TestDetails (com.teamscale.client.TestDetails)1 Benchmark (com.teamscale.jacoco.agent.util.Benchmark)1 TestwiseCoverageReportWriter (com.teamscale.report.testwise.TestwiseCoverageReportWriter)1 JaCoCoTestwiseReportGenerator (com.teamscale.report.testwise.jacoco.JaCoCoTestwiseReportGenerator)1 TestExecution (com.teamscale.report.testwise.model.TestExecution)1 TestInfoFactory (com.teamscale.report.testwise.model.factory.TestInfoFactory)1 CommandLineLogger (com.teamscale.report.util.CommandLineLogger)1 ILogger (com.teamscale.report.util.ILogger)1 File (java.io.File)1