Search in sources :

Example 1 with AvailableTests

use of com.teamscale.test_impacted.engine.executor.AvailableTests in project teamscale-jacoco-agent by cqse.

the class TestDescriptorUtils method getAvailableTests.

/**
 * Returns the {@link AvailableTests} contained within the root {@link TestDescriptor}.
 */
public static AvailableTests getAvailableTests(TestEngine testEngine, TestDescriptor rootTestDescriptor) {
    AvailableTests availableTests = new AvailableTests();
    ITestDescriptorResolver testDescriptorResolver = TestDescriptorResolverRegistry.getTestDescriptorResolver(testEngine);
    TestDescriptorUtils.streamTestRepresentatives(rootTestDescriptor).forEach(testDescriptor -> {
        Optional<String> clusterId = testDescriptorResolver.getClusterId(testDescriptor);
        Optional<String> uniformPath = testDescriptorResolver.getUniformPath(testDescriptor);
        String source = TestDescriptorUtils.getSource(testDescriptor);
        if (!uniformPath.isPresent()) {
            LOGGER.error(() -> "Unable to determine uniform path for test descriptor: " + testDescriptor);
            return;
        }
        if (!clusterId.isPresent()) {
            LOGGER.error(() -> "Unable to determine cluster id path for test descriptor: " + testDescriptor);
            return;
        }
        ClusteredTestDetails testDetails = new ClusteredTestDetails(uniformPath.get(), source, null, clusterId.get());
        availableTests.add(testDescriptor.getUniqueId(), testDetails);
    });
    return availableTests;
}
Also used : AvailableTests(com.teamscale.test_impacted.engine.executor.AvailableTests) ClusteredTestDetails(com.teamscale.client.ClusteredTestDetails)

Example 2 with AvailableTests

use of com.teamscale.test_impacted.engine.executor.AvailableTests 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

AvailableTests (com.teamscale.test_impacted.engine.executor.AvailableTests)2 ClusteredTestDetails (com.teamscale.client.ClusteredTestDetails)1 TestDetails (com.teamscale.client.TestDetails)1 TestExecution (com.teamscale.report.testwise.model.TestExecution)1 TestExecutorRequest (com.teamscale.test_impacted.engine.executor.TestExecutorRequest)1 ArrayList (java.util.ArrayList)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1 TestEngine (org.junit.platform.engine.TestEngine)1