use of org.junit.jupiter.engine.extension.MutableExtensionRegistry in project junit5 by junit-team.
the class JupiterEngineExecutionContextTests method extendWithAllAttributes.
@Test
void extendWithAllAttributes() {
ExtensionContext extensionContext = mock(ExtensionContext.class);
MutableExtensionRegistry extensionRegistry = MutableExtensionRegistry.createRegistryWithDefaultExtensions(configuration);
TestInstancesProvider testInstancesProvider = mock(TestInstancesProvider.class);
JupiterEngineExecutionContext newContext = //
originalContext.extend().withExtensionContext(//
extensionContext).withExtensionRegistry(//
extensionRegistry).withTestInstancesProvider(//
testInstancesProvider).build();
assertSame(extensionContext, newContext.getExtensionContext());
assertSame(extensionRegistry, newContext.getExtensionRegistry());
assertSame(testInstancesProvider, newContext.getTestInstancesProvider());
}
use of org.junit.jupiter.engine.extension.MutableExtensionRegistry in project junit5 by junit-team.
the class JupiterEngineDescriptor method prepare.
@Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context) {
MutableExtensionRegistry extensionRegistry = MutableExtensionRegistry.createRegistryWithDefaultExtensions(context.getConfiguration());
EngineExecutionListener executionListener = context.getExecutionListener();
ExecutableInvoker executableInvoker = new DefaultExecutableInvoker(context);
ExtensionContext extensionContext = new JupiterEngineExtensionContext(executionListener, this, context.getConfiguration(), executableInvoker);
// @formatter:off
return context.extend().withExtensionRegistry(extensionRegistry).withExtensionContext(extensionContext).build();
// @formatter:on
}
use of org.junit.jupiter.engine.extension.MutableExtensionRegistry in project junit5 by junit-team.
the class TestMethodTestDescriptor method prepare.
// --- Node ----------------------------------------------------------------
@Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context) {
MutableExtensionRegistry registry = populateNewExtensionRegistry(context);
ThrowableCollector throwableCollector = createThrowableCollector();
ExecutableInvoker executableInvoker = new DefaultExecutableInvoker(context);
MethodExtensionContext extensionContext = new MethodExtensionContext(context.getExtensionContext(), context.getExecutionListener(), this, context.getConfiguration(), throwableCollector, executableInvoker);
throwableCollector.execute(() -> {
TestInstances testInstances = context.getTestInstancesProvider().getTestInstances(registry, throwableCollector);
extensionContext.setTestInstances(testInstances);
});
// @formatter:off
return context.extend().withExtensionRegistry(registry).withExtensionContext(extensionContext).withThrowableCollector(throwableCollector).build();
// @formatter:on
}
use of org.junit.jupiter.engine.extension.MutableExtensionRegistry in project junit5 by junit-team.
the class TestTemplateTestDescriptor method prepare.
// --- Node ----------------------------------------------------------------
@Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context) throws Exception {
MutableExtensionRegistry registry = populateNewExtensionRegistryFromExtendWithAnnotation(context.getExtensionRegistry(), getTestMethod());
// The test instance should be properly maintained by the enclosing class's ExtensionContext.
TestInstances testInstances = context.getExtensionContext().getTestInstances().orElse(null);
ExecutableInvoker executableInvoker = new DefaultExecutableInvoker(context);
ExtensionContext extensionContext = new TestTemplateExtensionContext(context.getExtensionContext(), context.getExecutionListener(), this, context.getConfiguration(), testInstances, executableInvoker);
// @formatter:off
return context.extend().withExtensionRegistry(registry).withExtensionContext(extensionContext).build();
// @formatter:on
}
Aggregations