Search in sources :

Example 6 with TestDetails

use of com.teamscale.client.TestDetails 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)

Example 7 with TestDetails

use of com.teamscale.client.TestDetails in project teamscale-jacoco-agent by cqse.

the class InternalImpactedTestEngine method runTestExecutor.

private void runTestExecutor(ExecutionRequest request) {
    List<TestDetails> availableTests = new ArrayList<>();
    List<TestExecution> testExecutions = new ArrayList<>();
    for (TestDescriptor engineTestDescriptor : request.getRootTestDescriptor().getChildren()) {
        Optional<String> engineId = engineTestDescriptor.getUniqueId().getEngineId();
        if (!engineId.isPresent()) {
            LOGGER.error(() -> "Engine id for test descriptor " + engineTestDescriptor + " not present. Skipping execution of the engine.");
            continue;
        }
        TestEngine testEngine = testEngineRegistry.getTestEngine(engineId.get());
        AvailableTests availableTestsForEngine = TestDescriptorUtils.getAvailableTests(testEngine, engineTestDescriptor);
        TestExecutorRequest testExecutorRequest = new TestExecutorRequest(testEngine, engineTestDescriptor, request.getEngineExecutionListener(), request.getConfigurationParameters());
        List<TestExecution> testExecutionsOfEngine = testExecutor.execute(testExecutorRequest);
        testExecutions.addAll(testExecutionsOfEngine);
        availableTests.addAll(availableTestsForEngine.getTestList());
    }
    testDataWriter.dumpTestDetails(availableTests);
    testDataWriter.dumpTestExecutions(testExecutions);
}
Also used : AvailableTests(com.teamscale.test_impacted.engine.executor.AvailableTests) TestExecution(com.teamscale.report.testwise.model.TestExecution) ArrayList(java.util.ArrayList) TestExecutorRequest(com.teamscale.test_impacted.engine.executor.TestExecutorRequest) TestEngine(org.junit.platform.engine.TestEngine) TestDetails(com.teamscale.client.TestDetails) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Aggregations

TestDetails (com.teamscale.client.TestDetails)7 TestExecution (com.teamscale.report.testwise.model.TestExecution)6 ArrayList (java.util.ArrayList)3 TestInfoBuilder (com.teamscale.report.testwise.model.builder.TestInfoBuilder)2 Benchmark (com.teamscale.jacoco.agent.util.Benchmark)1 TestwiseCoverageReportWriter (com.teamscale.report.testwise.TestwiseCoverageReportWriter)1 JaCoCoTestwiseReportGenerator (com.teamscale.report.testwise.jacoco.JaCoCoTestwiseReportGenerator)1 TestInfo (com.teamscale.report.testwise.model.TestInfo)1 TestCoverageBuilder (com.teamscale.report.testwise.model.builder.TestCoverageBuilder)1 TestInfoFactory (com.teamscale.report.testwise.model.factory.TestInfoFactory)1 CommandLineLogger (com.teamscale.report.util.CommandLineLogger)1 ILogger (com.teamscale.report.util.ILogger)1 AvailableTests (com.teamscale.test_impacted.engine.executor.AvailableTests)1 TestExecutorRequest (com.teamscale.test_impacted.engine.executor.TestExecutorRequest)1 File (java.io.File)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1 TestEngine (org.junit.platform.engine.TestEngine)1