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 JupiterTestDescriptor
TestDescriptor for 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.SkipResultNested classes/interfaces inherited from interface org.junit.platform.engine.TestDescriptor
TestDescriptor.Type, TestDescriptor.Visitor -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Node.ExecutionModeprivate static final ExecutableInvokerprotected final TestInstance.Lifecycleprivate final Class<?> private TestInstanceFactoryFields inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
configurationFields inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
children -
Constructor Summary
ConstructorsConstructorDescriptionClassBasedTestDescriptor(UniqueId uniqueId, Class<?> testClass, Supplier<String> displayNameSupplier, JupiterConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidafter(JupiterEngineExecutionContext context) Execute the after behavior of this node.before(JupiterEngineExecutionContext context) Execute the before behavior of this node.private voidexecuteAndMaskThrowable(Executable executable) protected Optional<Node.ExecutionMode> Get the set of exclusive resources required to execute this node.protected Optional<Node.ExecutionMode> 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.final Class<?> getType()Determine theTestDescriptor.Typeof this descriptor.private TestInstancesinstantiateAndPostProcessTestInstance(JupiterEngineExecutionContext parentExecutionContext, ExtensionContext extensionContext, ExtensionRegistry registry, ExtensionRegistrar registrar, ThrowableCollector throwableCollector) protected TestInstancesinstantiateTestClass(Optional<TestInstances> outerInstances, ExtensionRegistry registry, ExtensionContext extensionContext) protected abstract TestInstancesinstantiateTestClass(JupiterEngineExecutionContext parentExecutionContext, ExtensionRegistry registry, ExtensionRegistrar registrar, ExtensionContext extensionContext, ThrowableCollector throwableCollector) private voidprivate voidinvokeAfterAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, Throwable throwable) private voidprivate voidprivate voidinvokeBeforeAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, Throwable throwable) private voidprivate voidinvokeMethodInExtensionContext(Method method, ExtensionContext context, ExtensionRegistry registry, ExecutableInvoker.ReflectiveInterceptorCall.VoidMethodInterceptorCall interceptorCall) private ObjectinvokeTestClassConstructor(Optional<Object> outerInstance, ExtensionRegistry registry, ExtensionContext extensionContext) private ObjectinvokeTestInstanceFactory(Optional<Object> outerInstance, ExtensionContext extensionContext) private voidinvokeTestInstancePostProcessors(Object instance, ExtensionRegistry registry, ExtensionContext context) private voidprivate booleanprepare(JupiterEngineExecutionContext context) Must be overridden and return a new context so cleanUp() does not accidentally close the parent context.private voidprivate voidprivate voidregisterMethodsAsExtensions(List<Method> methods, ExtensionRegistrar registrar, Function<Method, Extension> extensionSynthesizer) private TestInstanceFactoryresolveTestInstanceFactory(ExtensionRegistry registry) voidsetDefaultChildExecutionMode(Node.ExecutionMode defaultChildExecutionMode) private AfterEachMethodAdapterprivate BeforeEachMethodAdapterprivate TestInstancesProvidertestInstancesProvider(JupiterEngineExecutionContext parentExecutionContext, ClassExtensionContext extensionContext) Methods inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
cleanUp, getExclusiveResourcesFromAnnotation, getExecutionMode, getExecutionModeFromAnnotation, getTags, invokeExecutionExceptionHandlers, shouldBeSkipped, toExecutionModeMethods inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
addChild, equals, findByUniqueId, getChildren, getDisplayName, getParent, getSource, getTags, getUniqueId, hashCode, removeChild, removeFromHierarchy, setParent, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.junit.platform.engine.support.hierarchical.Node
around, execute, nodeFinished, nodeSkippedMethods inherited from interface org.junit.platform.engine.TestDescriptor
accept, getDescendants, isContainer, isRoot, isTest, mayRegisterTests, prune
-
Field Details
-
executableInvoker
-
testClass
-
tags
-
lifecycle
-
defaultChildExecutionMode
-
testInstanceFactory
-
beforeAllMethods
-
afterAllMethods
-
-
Constructor Details
-
ClassBasedTestDescriptor
ClassBasedTestDescriptor(UniqueId uniqueId, Class<?> testClass, Supplier<String> displayNameSupplier, JupiterConfiguration configuration)
-
-
Method Details
-
getTestClass
-
getEnclosingTestClasses
-
getType
Description copied from interface:TestDescriptorDetermine theTestDescriptor.Typeof this descriptor.- Returns:
- the descriptor type; never
null. - See Also:
-
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
- Overrides:
getExplicitExecutionModein classJupiterTestDescriptor
-
getDefaultChildExecutionMode
- Overrides:
getDefaultChildExecutionModein classJupiterTestDescriptor
-
setDefaultChildExecutionMode
-
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:
-
prepare
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:
-
before
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:
-
after
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:
-
resolveTestInstanceFactory
-
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(Optional<TestInstances> outerInstances, ExtensionRegistry registry, ExtensionContext extensionContext) -
invokeTestInstanceFactory
private Object invokeTestInstanceFactory(Optional<Object> outerInstance, ExtensionContext extensionContext) -
invokeTestClassConstructor
private Object invokeTestClassConstructor(Optional<Object> outerInstance, ExtensionRegistry registry, ExtensionContext extensionContext) -
invokeTestInstancePostProcessors
private void invokeTestInstancePostProcessors(Object instance, ExtensionRegistry registry, ExtensionContext context) -
executeAndMaskThrowable
-
invokeBeforeAllCallbacks
-
invokeBeforeAllMethods
-
invokeBeforeAllMethodExecutionExceptionHandlers
private void invokeBeforeAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, Throwable throwable) -
invokeAfterAllMethods
-
invokeAfterAllMethodExecutionExceptionHandlers
private void invokeAfterAllMethodExecutionExceptionHandlers(ExtensionRegistry registry, ExtensionContext context, Throwable throwable) -
invokeAfterAllCallbacks
-
invokeTestInstancePreDestroyCallbacks
-
isPerClassLifecycle
-
registerBeforeEachMethodAdapters
-
registerAfterEachMethodAdapters
-
registerMethodsAsExtensions
-
synthesizeBeforeEachMethodAdapter
-
synthesizeAfterEachMethodAdapter
-
invokeMethodInExtensionContext
private void invokeMethodInExtensionContext(Method method, ExtensionContext context, ExtensionRegistry registry, ExecutableInvoker.ReflectiveInterceptorCall.VoidMethodInterceptorCall interceptorCall)
-