Search in sources :

Example 1 with TestDetails

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

the class TestwiseCoverageReportBuilder method createFrom.

/**
 * Adds the {@link TestCoverageBuilder} to the map. If there is already a test with the same ID the coverage is
 * merged.
 */
public static TestwiseCoverageReport createFrom(Collection<? extends TestDetails> testDetailsList, Collection<TestCoverageBuilder> testCoverage, Collection<TestExecution> testExecutions) {
    TestwiseCoverageReportBuilder report = new TestwiseCoverageReportBuilder();
    for (TestDetails testDetails : testDetailsList) {
        TestInfoBuilder container = new TestInfoBuilder(testDetails.uniformPath);
        container.setDetails(testDetails);
        report.tests.put(testDetails.uniformPath, container);
    }
    for (TestCoverageBuilder coverage : testCoverage) {
        TestInfoBuilder container = resolveUniformPath(report, coverage.getUniformPath());
        if (container == null) {
            continue;
        }
        container.setCoverage(coverage);
    }
    for (TestExecution testExecution : testExecutions) {
        TestInfoBuilder container = resolveUniformPath(report, testExecution.getUniformPath());
        if (container == null) {
            continue;
        }
        container.setExecution(testExecution);
    }
    return report.build();
}
Also used : TestExecution(com.teamscale.report.testwise.model.TestExecution) TestDetails(com.teamscale.client.TestDetails)

Example 2 with TestDetails

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

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

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

the class TestInfoFactory method resolveUniformPath.

/**
 * Strips parameterized test arguments when the full path given in the coverage file cannot be found in the test
 * details.
 */
private String resolveUniformPath(String originalUniformPath) {
    String uniformPath = originalUniformPath;
    TestDetails testDetails = testDetailsMap.get(uniformPath);
    if (testDetails == null) {
        uniformPath = TestwiseCoverageReportBuilder.stripParameterizedTestArguments(uniformPath);
    }
    return uniformPath;
}
Also used : TestDetails(com.teamscale.client.TestDetails)

Example 5 with TestDetails

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

the class JaCoCoTestwiseReportGeneratorTest method generateDummyReportFrom.

/**
 * Generates a dummy coverage report object that wraps the given {@link TestwiseCoverage}.
 */
public static TestwiseCoverageReport generateDummyReportFrom(TestwiseCoverage testwiseCoverage) {
    ArrayList<TestDetails> testDetails = new ArrayList<>();
    for (TestCoverageBuilder test : testwiseCoverage.getTests()) {
        testDetails.add(new TestDetails(test.getUniformPath(), "/path/to/source", "content"));
    }
    ArrayList<TestExecution> testExecutions = new ArrayList<>();
    for (TestCoverageBuilder test : testwiseCoverage.getTests()) {
        testExecutions.add(new TestExecution(test.getUniformPath(), test.getUniformPath().length(), ETestExecutionResult.PASSED));
    }
    return TestwiseCoverageReportBuilder.createFrom(testDetails, testwiseCoverage.getTests(), testExecutions);
}
Also used : TestExecution(com.teamscale.report.testwise.model.TestExecution) TestCoverageBuilder(com.teamscale.report.testwise.model.builder.TestCoverageBuilder) ArrayList(java.util.ArrayList) TestDetails(com.teamscale.client.TestDetails)

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