@API(status=INTERNAL,
since="5.5")
public abstract class ClassBasedTestDescriptor
extends JupiterTestDescriptor
TestDescriptor for tests based on Java classes.JupiterTestDescriptor.ExceptionHandlerInvoker<E extends Extension>Node.DynamicTestExecutor, Node.ExecutionMode, Node.Invocation<C extends EngineExecutionContext>, Node.SkipResultTestDescriptor.Type, TestDescriptor.Visitor| Modifier and Type | Field and Description |
|---|---|
private java.util.List<java.lang.reflect.Method> |
afterAllMethods |
private java.util.List<java.lang.reflect.Method> |
beforeAllMethods |
private Node.ExecutionMode |
defaultChildExecutionMode |
private static ExecutableInvoker |
executableInvoker |
protected TestInstance.Lifecycle |
lifecycle |
protected java.util.Set<TestTag> |
tags |
private java.lang.Class<?> |
testClass |
private TestInstanceFactory |
testInstanceFactory |
configurationchildren| Constructor and Description |
|---|
ClassBasedTestDescriptor(UniqueId uniqueId,
java.lang.Class<?> testClass,
java.util.function.Supplier<java.lang.String> displayNameSupplier,
JupiterConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
void |
after(JupiterEngineExecutionContext context)
Execute the after behavior of this node.
|
JupiterEngineExecutionContext |
before(JupiterEngineExecutionContext context)
Execute the before behavior of this node.
|
private void |
executeAndMaskThrowable(Executable executable) |
protected java.util.Optional<Node.ExecutionMode> |
getDefaultChildExecutionMode() |
abstract java.util.List<java.lang.Class<?>> |
getEnclosingTestClasses() |
java.util.Set<ExclusiveResource> |
getExclusiveResources()
Get the set of exclusive resources
required to execute this node.
|
protected java.util.Optional<Node.ExecutionMode> |
getExplicitExecutionMode() |
java.lang.String |
getLegacyReportingName()
Get the name of this descriptor in a format that is suitable for legacy
reporting infrastructure — for example, for reporting systems built
on the Ant-based XML reporting format for JUnit 4.
|
java.lang.Class<?> |
getTestClass() |
TestDescriptor.Type |
getType()
Determine the
TestDescriptor.Type of this descriptor. |
private TestInstances |
instantiateAndPostProcessTestInstance(JupiterEngineExecutionContext parentExecutionContext,
ExtensionContext extensionContext,
ExtensionRegistry registry,
ExtensionRegistrar registrar) |
protected abstract TestInstances |
instantiateTestClass(JupiterEngineExecutionContext parentExecutionContext,
ExtensionRegistry registry,
ExtensionRegistrar registrar,
ExtensionContext extensionContext) |
protected TestInstances |
instantiateTestClass(java.util.Optional<TestInstances> outerInstances,
ExtensionRegistry registry,
ExtensionContext extensionContext) |
private void |
invokeAfterAllCallbacks(JupiterEngineExecutionContext context) |
private void |
invokeAfterAllMethodExecutionExceptionHandlers(ExtensionRegistry registry,
ExtensionContext context,
java.lang.Throwable throwable) |
private void |
invokeAfterAllMethods(JupiterEngineExecutionContext context) |
private void |
invokeBeforeAllCallbacks(JupiterEngineExecutionContext context) |
private void |
invokeBeforeAllMethodExecutionExceptionHandlers(ExtensionRegistry registry,
ExtensionContext context,
java.lang.Throwable throwable) |
private void |
invokeBeforeAllMethods(JupiterEngineExecutionContext context) |
private void |
invokeMethodInExtensionContext(java.lang.reflect.Method method,
ExtensionContext context,
ExtensionRegistry registry,
ExecutableInvoker.ReflectiveInterceptorCall.VoidMethodInterceptorCall interceptorCall) |
private java.lang.Object |
invokeTestClassConstructor(java.util.Optional<java.lang.Object> outerInstance,
ExtensionRegistry registry,
ExtensionContext extensionContext) |
private java.lang.Object |
invokeTestInstanceFactory(java.util.Optional<java.lang.Object> outerInstance,
ExtensionContext extensionContext) |
private void |
invokeTestInstancePostProcessors(java.lang.Object instance,
ExtensionRegistry registry,
ExtensionContext context) |
JupiterEngineExecutionContext |
prepare(JupiterEngineExecutionContext context)
Must be overridden and return a new context so cleanUp() does not accidentally close the parent context.
|
private void |
registerAfterEachMethodAdapters(ExtensionRegistrar registrar) |
private void |
registerBeforeEachMethodAdapters(ExtensionRegistrar registrar) |
private void |
registerMethodsAsExtensions(java.util.List<java.lang.reflect.Method> methods,
ExtensionRegistrar registrar,
java.util.function.Function<java.lang.reflect.Method,Extension> extensionSynthesizer) |
private TestInstanceFactory |
resolveTestInstanceFactory(ExtensionRegistry registry) |
void |
setDefaultChildExecutionMode(Node.ExecutionMode defaultChildExecutionMode) |
private AfterEachMethodAdapter |
synthesizeAfterEachMethodAdapter(java.lang.reflect.Method method) |
private BeforeEachMethodAdapter |
synthesizeBeforeEachMethodAdapter(java.lang.reflect.Method method) |
private TestInstancesProvider |
testInstancesProvider(JupiterEngineExecutionContext parentExecutionContext,
ClassExtensionContext extensionContext) |
cleanUp, getExclusiveResourcesFromAnnotation, getExecutionMode, getExecutionModeFromAnnotation, getTags, invokeExecutionExceptionHandlers, shouldBeSkipped, toExecutionModeaddChild, equals, findByUniqueId, getChildren, getDisplayName, getParent, getSource, getTags, getUniqueId, hashCode, removeChild, removeFromHierarchy, setParent, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaround, execute, nodeFinished, nodeSkippedaccept, containsTests, getDescendants, isContainer, isRoot, isTest, mayRegisterTests, pruneprivate static final ExecutableInvoker executableInvoker
private final java.lang.Class<?> testClass
protected final java.util.Set<TestTag> tags
protected final TestInstance.Lifecycle lifecycle
private Node.ExecutionMode defaultChildExecutionMode
private TestInstanceFactory testInstanceFactory
private java.util.List<java.lang.reflect.Method> beforeAllMethods
private java.util.List<java.lang.reflect.Method> afterAllMethods
ClassBasedTestDescriptor(UniqueId uniqueId, java.lang.Class<?> testClass, java.util.function.Supplier<java.lang.String> displayNameSupplier, JupiterConfiguration configuration)
public final java.lang.Class<?> getTestClass()
public abstract java.util.List<java.lang.Class<?>> getEnclosingTestClasses()
public TestDescriptor.Type getType()
TestDescriptorTestDescriptor.Type of this descriptor.null.TestDescriptor.isContainer(),
TestDescriptor.isTest()public java.lang.String getLegacyReportingName()
TestDescriptorThe default implementation simply delegates to TestDescriptor.getDisplayName().
null or blankprotected java.util.Optional<Node.ExecutionMode> getExplicitExecutionMode()
getExplicitExecutionMode in class JupiterTestDescriptorprotected java.util.Optional<Node.ExecutionMode> getDefaultChildExecutionMode()
getDefaultChildExecutionMode in class JupiterTestDescriptorpublic void setDefaultChildExecutionMode(Node.ExecutionMode defaultChildExecutionMode)
public java.util.Set<ExclusiveResource> getExclusiveResources()
NodeThe default implementation returns an empty set.
null but potentially emptyExclusiveResourcepublic JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context)
JupiterTestDescriptorprepare in interface Node<JupiterEngineExecutionContext>prepare in class JupiterTestDescriptorNode.cleanUp(EngineExecutionContext)public JupiterEngineExecutionContext before(JupiterEngineExecutionContext context)
NodeThis method will be called once before execution of this node.
The default implementation returns the supplied context unmodified.
context - the context to execute innullNode.execute(EngineExecutionContext, DynamicTestExecutor),
Node.after(EngineExecutionContext)public void after(JupiterEngineExecutionContext context)
NodeThis method will be called once after execution of this node.
The default implementation does nothing.
context - the context to execute inNode.before(C),
Node.execute(C, org.junit.platform.engine.support.hierarchical.Node.DynamicTestExecutor)private TestInstanceFactory resolveTestInstanceFactory(ExtensionRegistry registry)
private TestInstancesProvider testInstancesProvider(JupiterEngineExecutionContext parentExecutionContext, ClassExtensionContext extensionContext)
private TestInstances instantiateAndPostProcessTestInstance(JupiterEngineExecutionContext parentExecutionContext, ExtensionContext extensionContext, ExtensionRegistry registry, ExtensionRegistrar registrar)
protected abstract TestInstances instantiateTestClass(JupiterEngineExecutionContext parentExecutionContext, ExtensionRegistry registry, ExtensionRegistrar registrar, ExtensionContext extensionContext)
protected TestInstances instantiateTestClass(java.util.Optional<TestInstances> outerInstances, ExtensionRegistry registry, ExtensionContext extensionContext)
private java.lang.Object invokeTestInstanceFactory(java.util.Optional<java.lang.Object> outerInstance,
ExtensionContext extensionContext)
private java.lang.Object invokeTestClassConstructor(java.util.Optional<java.lang.Object> outerInstance,
ExtensionRegistry registry,
ExtensionContext extensionContext)
private void invokeTestInstancePostProcessors(java.lang.Object instance,
ExtensionRegistry registry,
ExtensionContext context)
private void executeAndMaskThrowable(Executable executable)
private void invokeBeforeAllCallbacks(JupiterEngineExecutionContext context)
private void invokeBeforeAllMethods(JupiterEngineExecutionContext context)
private void invokeBeforeAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, java.lang.Throwable throwable)
private void invokeAfterAllMethods(JupiterEngineExecutionContext context)
private void invokeAfterAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, java.lang.Throwable throwable)
private void invokeAfterAllCallbacks(JupiterEngineExecutionContext context)
private void registerBeforeEachMethodAdapters(ExtensionRegistrar registrar)
private void registerAfterEachMethodAdapters(ExtensionRegistrar registrar)
private void registerMethodsAsExtensions(java.util.List<java.lang.reflect.Method> methods,
ExtensionRegistrar registrar,
java.util.function.Function<java.lang.reflect.Method,Extension> extensionSynthesizer)
private BeforeEachMethodAdapter synthesizeBeforeEachMethodAdapter(java.lang.reflect.Method method)
private AfterEachMethodAdapter synthesizeAfterEachMethodAdapter(java.lang.reflect.Method method)
private void invokeMethodInExtensionContext(java.lang.reflect.Method method,
ExtensionContext context,
ExtensionRegistry registry,
ExecutableInvoker.ReflectiveInterceptorCall.VoidMethodInterceptorCall interceptorCall)