Module org.junit.jupiter.engine
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:
Node<JupiterEngineExecutionContext>
,TestDescriptor
- Direct Known Subclasses:
TestFactoryTestDescriptor
,TestTemplateInvocationTestDescriptor
@API(status=INTERNAL, since="5.0") public class TestMethodTestDescriptor extends MethodBasedTestDescriptor
TestDescriptor
for@Test
methods.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 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 static String
SEGMENT_TYPE
-
Fields inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
children
-
-
Constructor Summary
Constructors Constructor Description TestMethodTestDescriptor(UniqueId uniqueId, Class<?> testClass, Method testMethod, JupiterConfiguration configuration)
-
Method Summary
-
Methods inherited from class org.junit.jupiter.engine.descriptor.MethodBasedTestDescriptor
getExclusiveResources, getExplicitExecutionMode, getLegacyReportingName, getTags, getTestClass, getTestMethod, invokeTestWatchers, nodeSkipped
-
Methods inherited from class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
getExecutionMode, shouldBeSkipped, toExecutionMode
-
Methods inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
addChild, equals, findByUniqueId, getChildren, getDisplayName, getParent, getSource, 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
after, around, before
-
Methods inherited from interface org.junit.platform.engine.TestDescriptor
accept, getDescendants, isContainer, isRoot, isTest, mayRegisterTests, prune
-
-
-
-
Field Detail
-
SEGMENT_TYPE
public static final String SEGMENT_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TestMethodTestDescriptor
public TestMethodTestDescriptor(UniqueId uniqueId, Class<?> testClass, Method testMethod, JupiterConfiguration configuration)
-
-
Method Detail
-
getType
public TestDescriptor.Type getType()
Description copied from interface:TestDescriptor
Determine theTestDescriptor.Type
of this descriptor.- Returns:
- the descriptor type; never
null
. - See Also:
TestDescriptor.isContainer()
,TestDescriptor.isTest()
-
prepare
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context)
Description copied from class:JupiterTestDescriptor
Must be overridden and return a new context so cleanUp() does not accidentally close the parent context.- Specified by:
prepare
in interfaceNode<JupiterEngineExecutionContext>
- Specified by:
prepare
in classJupiterTestDescriptor
- See Also:
Node.cleanUp(EngineExecutionContext)
-
populateNewExtensionRegistry
protected MutableExtensionRegistry populateNewExtensionRegistry(JupiterEngineExecutionContext context)
-
execute
public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)
Description copied from interface:Node
Execute the behavior of this node.Containers typically do not implement this method since the
HierarchicalTestEngine
handles execution of their children.The supplied
dynamicTestExecutor
may be used to submit additional dynamic tests for immediate execution.The default implementation returns the supplied
context
unmodified.- 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 Exception
Description copied from interface:Node
Clean up the suppliedcontext
after execution.The default implementation does nothing.
- Specified by:
cleanUp
in interfaceNode<JupiterEngineExecutionContext>
- Overrides:
cleanUp
in classJupiterTestDescriptor
- Parameters:
context
- the context to execute in- Throws:
Exception
- See Also:
Node.prepare(EngineExecutionContext)
-
invokeTestMethod
protected void invokeTestMethod(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)
-
nodeFinished
public void nodeFinished(JupiterEngineExecutionContext context, TestDescriptor descriptor, TestExecutionResult result)
InvoketestSuccessful()
,testAborted()
, ortestFailed()
on each registeredTestWatcher
according 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
-
-