Class TestMethodTestDescriptor
- java.lang.Object
-
- org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
-
- org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
-
- org.junit.jupiter.engine.descriptor.MethodBasedTestDescriptor
-
- org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor
-
- All Implemented Interfaces:
ResourceLockAware,TestClassAware,Validatable,Node<JupiterEngineExecutionContext>,TestDescriptor
- Direct Known Subclasses:
TestFactoryTestDescriptor,TestTemplateInvocationTestDescriptor
@API(status=INTERNAL, since="5.0") public class TestMethodTestDescriptor extends MethodBasedTestDescriptorTestDescriptorfor@Testmethods.Default Display Names
The default display name for a test method is the name of the method concatenated with a comma-separated list of parameter types in parentheses. The names of parameter types are retrieved using
Class.getSimpleName(). For example, the default display name for the following test method istestUser(TestInfo, User).@Test void testUser(TestInfo testInfo, @Mock User user) { ... }- Since:
- 5.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
JupiterTestDescriptor.ExceptionHandlerInvoker<E extends org.junit.jupiter.api.extension.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 static InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Method,java.lang.Void>defaultInterceptorCallprivate static InterceptingExecutableInvokerexecutableInvokerprivate InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Method,java.lang.Void>interceptorCallstatic java.lang.StringSEGMENT_TYPE-
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 TestMethodTestDescriptor(UniqueId uniqueId, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, java.util.function.Supplier<java.util.List<java.lang.Class<?>>> enclosingInstanceTypes, JupiterConfiguration configuration)TestMethodTestDescriptor(UniqueId uniqueId, java.lang.String displayName, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, JupiterConfiguration configuration)TestMethodTestDescriptor(UniqueId uniqueId, java.lang.String displayName, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, JupiterConfiguration configuration, InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Method,java.lang.Void> interceptorCall)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp(JupiterEngineExecutionContext context)Clean up the suppliedcontextafter execution.JupiterEngineExecutionContextexecute(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)Execute the behavior of this node.TestDescriptor.TypegetType()Determine theTestDescriptor.Typeof this descriptor.private voidinvokeAfterEachCallbacks(JupiterEngineExecutionContext context)private voidinvokeAfterEachExecutionExceptionHandlers(org.junit.jupiter.api.extension.ExtensionContext context, ExtensionRegistry registry, java.lang.Throwable throwable)private voidinvokeAfterEachMethods(JupiterEngineExecutionContext context)private voidinvokeAfterTestExecutionCallbacks(JupiterEngineExecutionContext context)private voidinvokeBeforeEachCallbacks(JupiterEngineExecutionContext context)private voidinvokeBeforeEachExecutionExceptionHandlers(org.junit.jupiter.api.extension.ExtensionContext context, ExtensionRegistry registry, java.lang.Throwable throwable)private voidinvokeBeforeEachMethods(JupiterEngineExecutionContext context)private voidinvokeBeforeTestExecutionCallbacks(JupiterEngineExecutionContext context)private voidinvokeTestExecutionExceptionHandlers(ExtensionRegistry registry, org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Throwable throwable)private voidinvokeTestInstancePreDestroyCallbacks(JupiterEngineExecutionContext context)protected voidinvokeTestMethod(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)private booleanisPerMethodLifecycle(JupiterEngineExecutionContext context)voidnodeFinished(JupiterEngineExecutionContext context, TestDescriptor descriptor, TestExecutionResult result)InvoketestSuccessful(),testAborted(), ortestFailed()on each registeredTestWatcheraccording to the status of the suppliedTestExecutionResult, in reverse registration order.protected MutableExtensionRegistrypopulateNewExtensionRegistry(JupiterEngineExecutionContext context)JupiterEngineExecutionContextprepare(JupiterEngineExecutionContext context)Must be overridden and return a new context with a newExtensionContextso cleanUp() does not accidentally close the parent context.protected voidprepareExtensionContext(org.junit.jupiter.api.extension.ExtensionContext extensionContext)protected TestMethodTestDescriptorwithUniqueId(java.util.function.UnaryOperator<UniqueId> uniqueIdTransformer){@return shallow copy (without children) of this descriptor with the supplied unique ID}-
Methods inherited from class org.junit.jupiter.engine.descriptor.MethodBasedTestDescriptor
getEnclosingTestClasses, getExclusiveResourceCollector, getExplicitExecutionMode, getLegacyReportingName, getResourceLocksProviderEvaluator, getTags, getTestClass, getTestMethod, invokeTestWatchers, nodeSkipped, validate
-
Methods inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
copyIncludingDescendants, getDefaultChildExecutionMode, getExclusiveResources, getExecutionMode, getExecutionModeFromAnnotation, getTags, invokeExecutionExceptionHandlers, shouldBeSkipped, toExecutionMode
-
Methods inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
addChild, equals, findByUniqueId, getChildren, getDisplayName, getParent, getSource, getUniqueId, hashCode, orderChildren, 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
after, around, before
-
Methods inherited from interface org.junit.jupiter.engine.descriptor.ResourceLockAware
determineExclusiveResources, determineOwnExclusiveResources
-
Methods inherited from interface org.junit.platform.engine.TestDescriptor
accept, addChild, findByUniqueId, getAncestors, getChildren, getDescendants, getDisplayName, getParent, getSource, getUniqueId, isContainer, isRoot, isTest, mayRegisterTests, orderChildren, prune, removeChild, removeFromHierarchy, setParent
-
-
-
-
Field Detail
-
SEGMENT_TYPE
public static final java.lang.String SEGMENT_TYPE
- See Also:
- Constant Field Values
-
executableInvoker
private static final InterceptingExecutableInvoker executableInvoker
-
defaultInterceptorCall
private static final InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Method,java.lang.Void> defaultInterceptorCall
-
interceptorCall
private final InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Method,java.lang.Void> interceptorCall
-
-
Constructor Detail
-
TestMethodTestDescriptor
public TestMethodTestDescriptor(UniqueId uniqueId, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, java.util.function.Supplier<java.util.List<java.lang.Class<?>>> enclosingInstanceTypes, JupiterConfiguration configuration)
-
TestMethodTestDescriptor
TestMethodTestDescriptor(UniqueId uniqueId, java.lang.String displayName, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, JupiterConfiguration configuration)
-
TestMethodTestDescriptor
TestMethodTestDescriptor(UniqueId uniqueId, java.lang.String displayName, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod, JupiterConfiguration configuration, InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Method,java.lang.Void> interceptorCall)
-
-
Method Detail
-
withUniqueId
protected TestMethodTestDescriptor withUniqueId(java.util.function.UnaryOperator<UniqueId> uniqueIdTransformer)
Description copied from class:JupiterTestDescriptor{@return shallow copy (without children) of this descriptor with the supplied unique ID}- Specified by:
withUniqueIdin classJupiterTestDescriptor
-
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()
-
prepare
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context)
Description copied from class:JupiterTestDescriptorMust be overridden and return a new context with a newExtensionContextso cleanUp() does not accidentally close the parent context.- Specified by:
preparein interfaceNode<JupiterEngineExecutionContext>- Specified by:
preparein classJupiterTestDescriptor- See Also:
Node.cleanUp(EngineExecutionContext)
-
prepareExtensionContext
protected void prepareExtensionContext(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
-
populateNewExtensionRegistry
protected MutableExtensionRegistry populateNewExtensionRegistry(JupiterEngineExecutionContext context)
-
execute
public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)
Description copied from interface:NodeExecute the behavior of this node.Containers typically do not implement this method since the
HierarchicalTestEnginehandles execution of their children.The supplied
dynamicTestExecutormay be used to submit additional dynamic tests for immediate execution.The default implementation returns the supplied
contextunmodified.- Parameters:
context- the context to execute indynamicTestExecutor- the executor to submit dynamic tests to- Returns:
- the new context to be used for children of this node and for the after behavior of the parent of this node, if any
- See Also:
Node.before(C),Node.after(C)
-
cleanUp
public void cleanUp(JupiterEngineExecutionContext context) throws java.lang.Exception
Description copied from interface:NodeClean up the suppliedcontextafter execution.The default implementation does nothing.
- Specified by:
cleanUpin interfaceNode<JupiterEngineExecutionContext>- Overrides:
cleanUpin classJupiterTestDescriptor- Parameters:
context- the context to execute in- Throws:
java.lang.Exception- See Also:
Node.prepare(EngineExecutionContext)
-
isPerMethodLifecycle
private boolean isPerMethodLifecycle(JupiterEngineExecutionContext context)
-
invokeBeforeEachCallbacks
private void invokeBeforeEachCallbacks(JupiterEngineExecutionContext context)
-
invokeBeforeEachMethods
private void invokeBeforeEachMethods(JupiterEngineExecutionContext context)
-
invokeBeforeEachExecutionExceptionHandlers
private void invokeBeforeEachExecutionExceptionHandlers(org.junit.jupiter.api.extension.ExtensionContext context, ExtensionRegistry registry, java.lang.Throwable throwable)
-
invokeBeforeTestExecutionCallbacks
private void invokeBeforeTestExecutionCallbacks(JupiterEngineExecutionContext context)
-
invokeTestMethod
protected void invokeTestMethod(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)
-
invokeTestExecutionExceptionHandlers
private void invokeTestExecutionExceptionHandlers(ExtensionRegistry registry, org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Throwable throwable)
-
invokeAfterTestExecutionCallbacks
private void invokeAfterTestExecutionCallbacks(JupiterEngineExecutionContext context)
-
invokeAfterEachMethods
private void invokeAfterEachMethods(JupiterEngineExecutionContext context)
-
invokeAfterEachExecutionExceptionHandlers
private void invokeAfterEachExecutionExceptionHandlers(org.junit.jupiter.api.extension.ExtensionContext context, ExtensionRegistry registry, java.lang.Throwable throwable)
-
invokeAfterEachCallbacks
private void invokeAfterEachCallbacks(JupiterEngineExecutionContext context)
-
invokeTestInstancePreDestroyCallbacks
private void invokeTestInstancePreDestroyCallbacks(JupiterEngineExecutionContext context)
-
nodeFinished
public void nodeFinished(JupiterEngineExecutionContext context, TestDescriptor descriptor, TestExecutionResult result)
InvoketestSuccessful(),testAborted(), ortestFailed()on each registeredTestWatcheraccording to the status of the suppliedTestExecutionResult, in reverse registration order.- Parameters:
context- the execution contextdescriptor- the test descriptor that was executedresult- the result of the execution- Since:
- 5.4
-
-