private void execute(RootTestDescriptor root) { TestPlan testPlan = TestPlan.from(root); TestExecutionListener testExecutionListener = listenerRegistry.getCompositeTestExecutionListener(); testExecutionListener.testPlanExecutionStarted(testPlan); ExecutionListenerAdapter engineExecutionListener = new ExecutionListenerAdapter(testPlan, testExecutionListener); for (TestEngine testEngine : root.getTestEngines()) { TestDescriptor testDescriptor = root.getTestDescriptorFor(testEngine); testEngine.execute(new ExecutionRequest(testDescriptor, engineExecutionListener)); } testExecutionListener.testPlanExecutionFinished(testPlan); }
private RootTestDescriptor discoverRootDescriptor( TestPlanSpecification specification, String phase) { RootTestDescriptor root = new RootTestDescriptor(); for (TestEngine testEngine : testEngineRegistry.getTestEngines()) { LOG.fine( () -> String.format( "Discovering tests during launcher %s phase in engine '%s'.", phase, testEngine.getId())); EngineAwareTestDescriptor engineRoot = testEngine.discoverTests(specification); root.addChild(engineRoot); } root.applyFilters(specification); root.prune(); return root; }
TestDescriptor getTestDescriptorFor(TestEngine testEngine) { // @formatter:off return getChildren() .stream() .map(EngineAwareTestDescriptor.class::cast) .filter(testDescriptor -> Objects.equals(testEngine, testDescriptor.getEngine())) .findAny() .orElseThrow( () -> new IllegalArgumentException( "No TestDescriptor for TestEngine with ID: " + testEngine.getId())); // @formatter:on }