Class ClassBasedTestDescriptor
- java.lang.Object
-
- org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
-
- org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
-
- org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor
-
- All Implemented Interfaces:
Node<JupiterEngineExecutionContext>,TestDescriptor
- Direct Known Subclasses:
ClassTestDescriptor,NestedClassTestDescriptor
@API(status=INTERNAL, since="5.5") public abstract class ClassBasedTestDescriptor extends JupiterTestDescriptorTestDescriptorfor tests based on Java classes.- Since:
- 5.5
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
JupiterTestDescriptor.ExceptionHandlerInvoker<E extends Extension>
-
Nested classes/interfaces inherited from interface org.junit.platform.engine.support.hierarchical.Node
Node.DynamicTestExecutor, Node.ExecutionMode, Node.Invocation<C extends EngineExecutionContext>, Node.SkipResult
-
Nested classes/interfaces inherited from interface org.junit.platform.engine.TestDescriptor
TestDescriptor.Type, TestDescriptor.Visitor
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.reflect.Method>afterAllMethodsprivate java.util.List<java.lang.reflect.Method>beforeAllMethodsprivate Node.ExecutionModedefaultChildExecutionModeprivate static ExecutableInvokerexecutableInvokerprotected TestInstance.Lifecyclelifecycleprotected java.util.Set<TestTag>tagsprivate java.lang.Class<?>testClassprivate TestInstanceFactorytestInstanceFactory-
Fields inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
configuration
-
Fields inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
children
-
-
Constructor Summary
Constructors Constructor Description ClassBasedTestDescriptor(UniqueId uniqueId, java.lang.Class<?> testClass, java.util.function.Supplier<java.lang.String> displayNameSupplier, JupiterConfiguration configuration)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidafter(JupiterEngineExecutionContext context)Execute the after behavior of this node.JupiterEngineExecutionContextbefore(JupiterEngineExecutionContext context)Execute the before behavior of this node.private voidexecuteAndMaskThrowable(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.StringgetLegacyReportingName()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.TypegetType()Determine theTestDescriptor.Typeof this descriptor.private TestInstancesinstantiateAndPostProcessTestInstance(JupiterEngineExecutionContext parentExecutionContext, ExtensionContext extensionContext, ExtensionRegistry registry, ExtensionRegistrar registrar, ThrowableCollector throwableCollector)protected TestInstancesinstantiateTestClass(java.util.Optional<TestInstances> outerInstances, ExtensionRegistry registry, ExtensionContext extensionContext)protected abstract TestInstancesinstantiateTestClass(JupiterEngineExecutionContext parentExecutionContext, ExtensionRegistry registry, ExtensionRegistrar registrar, ExtensionContext extensionContext, ThrowableCollector throwableCollector)private voidinvokeAfterAllCallbacks(JupiterEngineExecutionContext context)private voidinvokeAfterAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, java.lang.Throwable throwable)private voidinvokeAfterAllMethods(JupiterEngineExecutionContext context)private voidinvokeBeforeAllCallbacks(JupiterEngineExecutionContext context)private voidinvokeBeforeAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, java.lang.Throwable throwable)private voidinvokeBeforeAllMethods(JupiterEngineExecutionContext context)private voidinvokeMethodInExtensionContext(java.lang.reflect.Method method, ExtensionContext context, ExtensionRegistry registry, ExecutableInvoker.ReflectiveInterceptorCall.VoidMethodInterceptorCall interceptorCall)private java.lang.ObjectinvokeTestClassConstructor(java.util.Optional<java.lang.Object> outerInstance, ExtensionRegistry registry, ExtensionContext extensionContext)private java.lang.ObjectinvokeTestInstanceFactory(java.util.Optional<java.lang.Object> outerInstance, ExtensionContext extensionContext)private voidinvokeTestInstancePostProcessors(java.lang.Object instance, ExtensionRegistry registry, ExtensionContext context)private voidinvokeTestInstancePreDestroyCallbacks(JupiterEngineExecutionContext context)private booleanisPerClassLifecycle(JupiterEngineExecutionContext context)JupiterEngineExecutionContextprepare(JupiterEngineExecutionContext context)Must be overridden and return a new context so cleanUp() does not accidentally close the parent context.private voidregisterAfterEachMethodAdapters(ExtensionRegistrar registrar)private voidregisterBeforeEachMethodAdapters(ExtensionRegistrar registrar)private voidregisterMethodsAsExtensions(java.util.List<java.lang.reflect.Method> methods, ExtensionRegistrar registrar, java.util.function.Function<java.lang.reflect.Method,Extension> extensionSynthesizer)private TestInstanceFactoryresolveTestInstanceFactory(ExtensionRegistry registry)voidsetDefaultChildExecutionMode(Node.ExecutionMode defaultChildExecutionMode)private AfterEachMethodAdaptersynthesizeAfterEachMethodAdapter(java.lang.reflect.Method method)private BeforeEachMethodAdaptersynthesizeBeforeEachMethodAdapter(java.lang.reflect.Method method)private TestInstancesProvidertestInstancesProvider(JupiterEngineExecutionContext parentExecutionContext, ClassExtensionContext extensionContext)-
Methods inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
cleanUp, getExclusiveResourcesFromAnnotation, getExecutionMode, getExecutionModeFromAnnotation, getTags, invokeExecutionExceptionHandlers, shouldBeSkipped, toExecutionMode
-
Methods inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
addChild, equals, findByUniqueId, getChildren, getDisplayName, getParent, getSource, getTags, getUniqueId, hashCode, removeChild, removeFromHierarchy, setParent, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.junit.platform.engine.support.hierarchical.Node
around, execute, nodeFinished, nodeSkipped
-
Methods inherited from interface org.junit.platform.engine.TestDescriptor
accept, getDescendants, isContainer, isRoot, isTest, mayRegisterTests, prune
-
-
-
-
Field Detail
-
executableInvoker
private static final ExecutableInvoker executableInvoker
-
testClass
private final java.lang.Class<?> testClass
-
tags
protected final java.util.Set<TestTag> tags
-
lifecycle
protected final TestInstance.Lifecycle lifecycle
-
defaultChildExecutionMode
private Node.ExecutionMode defaultChildExecutionMode
-
testInstanceFactory
private TestInstanceFactory testInstanceFactory
-
beforeAllMethods
private java.util.List<java.lang.reflect.Method> beforeAllMethods
-
afterAllMethods
private java.util.List<java.lang.reflect.Method> afterAllMethods
-
-
Constructor Detail
-
ClassBasedTestDescriptor
ClassBasedTestDescriptor(UniqueId uniqueId, java.lang.Class<?> testClass, java.util.function.Supplier<java.lang.String> displayNameSupplier, JupiterConfiguration configuration)
-
-
Method Detail
-
getTestClass
public final java.lang.Class<?> getTestClass()
-
getEnclosingTestClasses
public abstract java.util.List<java.lang.Class<?>> getEnclosingTestClasses()
-
getType
public TestDescriptor.Type getType()
Description copied from interface:TestDescriptorDetermine theTestDescriptor.Typeof this descriptor.- Returns:
- the descriptor type; never
null. - See Also:
TestDescriptor.isContainer(),TestDescriptor.isTest()
-
getLegacyReportingName
public java.lang.String getLegacyReportingName()
Description copied from interface:TestDescriptorGet 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.The default implementation simply delegates to
TestDescriptor.getDisplayName().- Returns:
- the legacy reporting name; never
nullor blank
-
getExplicitExecutionMode
protected java.util.Optional<Node.ExecutionMode> getExplicitExecutionMode()
- Overrides:
getExplicitExecutionModein classJupiterTestDescriptor
-
getDefaultChildExecutionMode
protected java.util.Optional<Node.ExecutionMode> getDefaultChildExecutionMode()
- Overrides:
getDefaultChildExecutionModein classJupiterTestDescriptor
-
setDefaultChildExecutionMode
public void setDefaultChildExecutionMode(Node.ExecutionMode defaultChildExecutionMode)
-
getExclusiveResources
public java.util.Set<ExclusiveResource> getExclusiveResources()
Description copied from interface:NodeGet the set of exclusive resources required to execute this node.The default implementation returns an empty set.
- Returns:
- the set of exclusive resources required by this node; never
nullbut potentially empty - See Also:
ExclusiveResource
-
prepare
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context)
Description copied from class:JupiterTestDescriptorMust be overridden and return a new context so cleanUp() does not accidentally close the parent context.- Specified by:
preparein interfaceNode<JupiterEngineExecutionContext>- Specified by:
preparein classJupiterTestDescriptor- See Also:
Node.cleanUp(EngineExecutionContext)
-
before
public JupiterEngineExecutionContext before(JupiterEngineExecutionContext context)
Description copied from interface:NodeExecute the before behavior of this node.This method will be called once before execution of this node.
The default implementation returns the supplied
contextunmodified.- Parameters:
context- the context to execute in- Returns:
- the new context to be used for children of this node; never
null - See Also:
Node.execute(EngineExecutionContext, DynamicTestExecutor),Node.after(EngineExecutionContext)
-
after
public void after(JupiterEngineExecutionContext context)
Description copied from interface:NodeExecute the after behavior of this node.This method will be called once after execution of this node.
The default implementation does nothing.
- Parameters:
context- the context to execute in- See Also:
Node.before(C),Node.execute(C, org.junit.platform.engine.support.hierarchical.Node.DynamicTestExecutor)
-
resolveTestInstanceFactory
private TestInstanceFactory resolveTestInstanceFactory(ExtensionRegistry registry)
-
testInstancesProvider
private TestInstancesProvider testInstancesProvider(JupiterEngineExecutionContext parentExecutionContext, ClassExtensionContext extensionContext)
-
instantiateAndPostProcessTestInstance
private TestInstances instantiateAndPostProcessTestInstance(JupiterEngineExecutionContext parentExecutionContext, ExtensionContext extensionContext, ExtensionRegistry registry, ExtensionRegistrar registrar, ThrowableCollector throwableCollector)
-
instantiateTestClass
protected abstract TestInstances instantiateTestClass(JupiterEngineExecutionContext parentExecutionContext, ExtensionRegistry registry, ExtensionRegistrar registrar, ExtensionContext extensionContext, ThrowableCollector throwableCollector)
-
instantiateTestClass
protected TestInstances instantiateTestClass(java.util.Optional<TestInstances> outerInstances, ExtensionRegistry registry, ExtensionContext extensionContext)
-
invokeTestInstanceFactory
private java.lang.Object invokeTestInstanceFactory(java.util.Optional<java.lang.Object> outerInstance, ExtensionContext extensionContext)
-
invokeTestClassConstructor
private java.lang.Object invokeTestClassConstructor(java.util.Optional<java.lang.Object> outerInstance, ExtensionRegistry registry, ExtensionContext extensionContext)
-
invokeTestInstancePostProcessors
private void invokeTestInstancePostProcessors(java.lang.Object instance, ExtensionRegistry registry, ExtensionContext context)
-
executeAndMaskThrowable
private void executeAndMaskThrowable(Executable executable)
-
invokeBeforeAllCallbacks
private void invokeBeforeAllCallbacks(JupiterEngineExecutionContext context)
-
invokeBeforeAllMethods
private void invokeBeforeAllMethods(JupiterEngineExecutionContext context)
-
invokeBeforeAllMethodExecutionExceptionHandlers
private void invokeBeforeAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, java.lang.Throwable throwable)
-
invokeAfterAllMethods
private void invokeAfterAllMethods(JupiterEngineExecutionContext context)
-
invokeAfterAllMethodExecutionExceptionHandlers
private void invokeAfterAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, java.lang.Throwable throwable)
-
invokeAfterAllCallbacks
private void invokeAfterAllCallbacks(JupiterEngineExecutionContext context)
-
invokeTestInstancePreDestroyCallbacks
private void invokeTestInstancePreDestroyCallbacks(JupiterEngineExecutionContext context)
-
isPerClassLifecycle
private boolean isPerClassLifecycle(JupiterEngineExecutionContext context)
-
registerBeforeEachMethodAdapters
private void registerBeforeEachMethodAdapters(ExtensionRegistrar registrar)
-
registerAfterEachMethodAdapters
private void registerAfterEachMethodAdapters(ExtensionRegistrar registrar)
-
registerMethodsAsExtensions
private void registerMethodsAsExtensions(java.util.List<java.lang.reflect.Method> methods, ExtensionRegistrar registrar, java.util.function.Function<java.lang.reflect.Method,Extension> extensionSynthesizer)
-
synthesizeBeforeEachMethodAdapter
private BeforeEachMethodAdapter synthesizeBeforeEachMethodAdapter(java.lang.reflect.Method method)
-
synthesizeAfterEachMethodAdapter
private AfterEachMethodAdapter synthesizeAfterEachMethodAdapter(java.lang.reflect.Method method)
-
invokeMethodInExtensionContext
private void invokeMethodInExtensionContext(java.lang.reflect.Method method, ExtensionContext context, ExtensionRegistry registry, ExecutableInvoker.ReflectiveInterceptorCall.VoidMethodInterceptorCall interceptorCall)
-
-