Search in sources :

Example 1 with TestInfoBuilder

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

the class TestInfoFactory method createTestInfosWithoutCoverage.

/**
 * Returns {@link TestInfo}s for all tests that have not been used yet in {@link #createFor(TestCoverageBuilder)}.
 */
public List<TestInfo> createTestInfosWithoutCoverage() {
    ArrayList<TestInfo> results = new ArrayList<>();
    for (TestDetails testDetails : testDetailsMap.values()) {
        if (!processedTestUniformPaths.contains(testDetails.uniformPath)) {
            TestInfoBuilder testInfo = new TestInfoBuilder(testDetails.uniformPath);
            testInfo.setDetails(testDetails);
            testInfo.setExecution(testExecutionsMap.get(testDetails.uniformPath));
            results.add(testInfo.build());
            processedTestUniformPaths.add(testDetails.uniformPath);
        }
    }
    for (TestExecution testExecution : testExecutionsMap.values()) {
        if (!processedTestUniformPaths.contains(testExecution.getUniformPath())) {
            System.err.println("Test " + testExecution.getUniformPath() + " was executed but no coverage was found. " + "Please make sure that you did provide all relevant exec files and that the test IDs passed to " + "the agent match the ones from the provided test execution list.");
            processedTestUniformPaths.add(testExecution.getUniformPath());
        }
    }
    return results;
}
Also used : TestExecution(com.teamscale.report.testwise.model.TestExecution) ArrayList(java.util.ArrayList) TestInfoBuilder(com.teamscale.report.testwise.model.builder.TestInfoBuilder) TestInfo(com.teamscale.report.testwise.model.TestInfo) TestDetails(com.teamscale.client.TestDetails)

Example 2 with TestInfoBuilder

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

the class TestInfoFactory method createFor.

/**
 * Converts the given {@link TestCoverageBuilder} to a {@link TestInfo} using the internally stored test details and
 * test executions.
 */
public TestInfo createFor(TestCoverageBuilder testCoverageBuilder) {
    String resolvedUniformPath = resolveUniformPath(testCoverageBuilder.getUniformPath());
    processedTestUniformPaths.add(resolvedUniformPath);
    TestInfoBuilder container = new TestInfoBuilder(resolvedUniformPath);
    container.setCoverage(testCoverageBuilder);
    TestDetails testDetails = testDetailsMap.get(resolvedUniformPath);
    if (testDetails == null) {
        System.err.println("No test details found for " + resolvedUniformPath);
    }
    container.setDetails(testDetails);
    TestExecution execution = testExecutionsMap.get(resolvedUniformPath);
    if (execution == null) {
        System.err.println("No test execution found for " + resolvedUniformPath);
    }
    container.setExecution(execution);
    return container.build();
}
Also used : TestExecution(com.teamscale.report.testwise.model.TestExecution) TestInfoBuilder(com.teamscale.report.testwise.model.builder.TestInfoBuilder) TestDetails(com.teamscale.client.TestDetails)

Example 3 with TestInfoBuilder

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

the class CoverageViaHttpStrategy method testEnd.

@Override
public String testEnd(String test, TestExecution testExecution) throws JacocoRuntimeController.DumpException, CoverageGenerationException {
    super.testEnd(test, testExecution);
    TestInfoBuilder builder = new TestInfoBuilder(test);
    Dump dump = controller.dumpAndReset();
    builder.setCoverage(reportGenerator.convert(dump));
    if (testExecution != null) {
        builder.setExecution(testExecution);
    }
    TestInfo testInfo = builder.build();
    String testInfoJson = testInfoJsonAdapter.toJson(testInfo);
    logger.debug("Generated test info {}", testInfoJson);
    return testInfoJson;
}
Also used : Dump(com.teamscale.report.jacoco.dump.Dump) TestInfoBuilder(com.teamscale.report.testwise.model.builder.TestInfoBuilder) TestInfo(com.teamscale.report.testwise.model.TestInfo)

Aggregations

TestInfoBuilder (com.teamscale.report.testwise.model.builder.TestInfoBuilder)3 TestDetails (com.teamscale.client.TestDetails)2 TestExecution (com.teamscale.report.testwise.model.TestExecution)2 TestInfo (com.teamscale.report.testwise.model.TestInfo)2 Dump (com.teamscale.report.jacoco.dump.Dump)1 ArrayList (java.util.ArrayList)1