diff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java index aa22bcbe70aa..aa83e456fa39 100644 --- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java +++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java @@ -101,12 +101,11 @@ public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext conte context.getExtensionRegistry()); AtomicInteger invocationIndex = new AtomicInteger(); // @formatter:off - providers.stream() - .flatMap(provider -> provider.provideTestTemplateInvocationContexts(extensionContext)) - .map(invocationContext -> createInvocationTestDescriptor(invocationContext, invocationIndex.incrementAndGet())) - .filter(Optional::isPresent) - .map(Optional::get) - .forEach(invocationTestDescriptor -> execute(dynamicTestExecutor, invocationTestDescriptor)); + for (TestTemplateInvocationContextProvider provider : providers) { + provider.provideTestTemplateInvocationContexts(extensionContext) + .forEach(invocationContext -> createInvocationTestDescriptor(invocationContext, invocationIndex.incrementAndGet()) + .ifPresent(invocationTestDescriptor -> execute(dynamicTestExecutor, invocationTestDescriptor))); + } // @formatter:on validateWasAtLeastInvokedOnce(invocationIndex.get(), providers); return context;