private void executeAllChildren(RunnerExecutor runnerExecutor, TestDescriptor engineTestDescriptor) { // @formatter:off engineTestDescriptor.getChildren() .stream() .map(RunnerTestDescriptor.class::cast) .forEach(runnerExecutor::execute); // @formatter:on }
private boolean canFinish(TestDescriptor testDescriptor) { return testRun.isNotFinished(testDescriptor) // && testRun.isDescendantOfRunnerTestDescriptor(testDescriptor) && testRun.areAllFinishedOrSkipped(testDescriptor.getChildren()); }
private void doForChildrenRecursively(TestDescriptor parent, Consumer<TestDescriptor> consumer) { parent.getChildren().forEach(child -> { consumer.accept(child); doForChildrenRecursively(child, consumer); }); }
/** * Get the immutable set of all <em>descendants</em> of this descriptor. * * <p>A <em>descendant</em> is a child of this descriptor or a child of one of * its children, recursively. * * @see #getChildren() */ default Set<? extends TestDescriptor> getDescendants() { Set<TestDescriptor> descendants = new LinkedHashSet<>(); descendants.addAll(getChildren()); for (TestDescriptor child : getChildren()) { descendants.addAll(child.getDescendants()); } return Collections.unmodifiableSet(descendants); }
/** * Determine if the supplied descriptor (or any of its descendants) * {@linkplain TestDescriptor#isTest() is a test} or * {@linkplain TestDescriptor#mayRegisterTests() may potentially register * tests dynamically}. * * @param testDescriptor the {@code TestDescriptor} to check for tests; never * {@code null} * @return {@code true} if the descriptor is a test, contains tests, or may * later register tests dynamically */ static boolean containsTests(TestDescriptor testDescriptor) { Preconditions.notNull(testDescriptor, "TestDescriptor must not be null"); return testDescriptor.isTest() || testDescriptor.mayRegisterTests() || testDescriptor.getChildren().stream().anyMatch(TestDescriptor::containsTests); }
/** * Accept a {@link Visitor} to the subtree starting with this descriptor. * * @param visitor the {@code Visitor} to accept; never {@code null} */ default void accept(Visitor visitor) { Preconditions.notNull(visitor, "Visitor must not be null"); visitor.visit(this); // Create a copy of the set in order to avoid a ConcurrentModificationException new LinkedHashSet<>(this.getChildren()).forEach(child -> child.accept(visitor)); }
public Set<? extends TestDescriptor> getChildren() { return testDescriptor.getChildren().stream() .map((discover1) -> (TestDescriptor) createTestDescriptorForCucumber(discover1, containers)) .collect(Collectors.toSet()); }
private void walk(TestDescriptor testDescriptor, NodeExecutionAdvisor advisor) { Set<ExclusiveResource> exclusiveResources = getExclusiveResources(testDescriptor); if (exclusiveResources.isEmpty()) { testDescriptor.getChildren().forEach(child -> walk(child, advisor)); } else { Set<ExclusiveResource> allResources = new HashSet<>(exclusiveResources); advisor.forceDescendantExecutionMode(testDescriptor, SAME_THREAD); doForChildrenRecursively(testDescriptor, child -> { allResources.addAll(getExclusiveResources(child)); advisor.forceDescendantExecutionMode(child, SAME_THREAD); }); advisor.useResourceLock(testDescriptor, lockManager.getLockForResources(allResources)); } }
private void executeRecursively() { taskContext.getListener().executionStarted(testDescriptor); started = true; throwableCollector.execute(() -> { node.around(context, ctx -> { context = ctx; throwableCollector.execute(() -> { // @formatter:off List<NodeTestTask<C>> children = testDescriptor.getChildren().stream() .map(descriptor -> new NodeTestTask<C>(taskContext, descriptor)) .collect(toCollection(ArrayList::new)); // @formatter:on context = node.before(context); final DynamicTestExecutor dynamicTestExecutor = new DefaultDynamicTestExecutor(); context = node.execute(context, dynamicTestExecutor); if (!children.isEmpty()) { children.forEach(child -> child.setParentContext(context)); taskContext.getExecutorService().invokeAll(children); } throwableCollector.execute(dynamicTestExecutor::awaitFinished); }); throwableCollector.execute(() -> node.after(context)); }); }); }