use of org.junit.jupiter.engine.execution.JupiterEngineExecutionContext in project junit5 by junit-team.
the class TestFactoryTestDescriptorTests method before.
@BeforeEach
void before() throws Exception {
extensionContext = mock(ExtensionContext.class);
isClosed = false;
context = new JupiterEngineExecutionContext(null, null).extend().withThrowableCollector(new ThrowableCollector()).withExtensionContext(extensionContext).build();
Method testMethod = CustomStreamTestCase.class.getDeclaredMethod("customStream");
descriptor = new TestFactoryTestDescriptor(UniqueId.forEngine("engine"), CustomStreamTestCase.class, testMethod);
when(extensionContext.getTestMethod()).thenReturn(Optional.of(testMethod));
}
use of org.junit.jupiter.engine.execution.JupiterEngineExecutionContext in project junit5 by junit-team.
the class TestTemplateTestDescriptor method execute.
@Override
public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext context, DynamicTestExecutor dynamicTestExecutor) throws Exception {
ExtensionContext extensionContext = context.getExtensionContext();
List<TestTemplateInvocationContextProvider> providers = validateProviders(extensionContext, 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));
// @formatter:on
validateWasAtLeastInvokedOnce(invocationIndex.get());
return context;
}
use of org.junit.jupiter.engine.execution.JupiterEngineExecutionContext in project junit5 by junit-team.
the class TestMethodTestDescriptor method invokeAfterEachMethods.
private void invokeAfterEachMethods(JupiterEngineExecutionContext context) {
ExtensionRegistry registry = context.getExtensionRegistry();
invokeAllAfterMethodsOrCallbacks(context, ((extensionContext, adapter) -> () -> adapter.invokeAfterEachMethod(extensionContext, registry)), AfterEachMethodAdapter.class);
}
use of org.junit.jupiter.engine.execution.JupiterEngineExecutionContext in project junit5 by junit-team.
the class TestMethodTestDescriptor method invokeBeforeEachMethods.
private void invokeBeforeEachMethods(JupiterEngineExecutionContext context) {
ExtensionRegistry registry = context.getExtensionRegistry();
invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(context, ((extensionContext, adapter) -> () -> adapter.invokeBeforeEachMethod(extensionContext, registry)), BeforeEachMethodAdapter.class);
}
Aggregations