Class TestMethodTestDescriptor
- java.lang.Object
-
- org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
-
- org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
-
- 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 JupiterTestDescriptor
TestDescriptorfor tests based on Java 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.SkipResult
-
Nested classes/interfaces inherited from interface org.junit.platform.engine.TestDescriptor
TestDescriptor.Type, TestDescriptor.Visitor
-
-
Field Summary
-
Fields inherited from class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
children
-
-
Constructor Summary
Constructors Constructor Description TestMethodTestDescriptor(UniqueId uniqueId, Class<?> testClass, Method testMethod)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JupiterEngineExecutionContextexecute(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)Execute the behavior of this node.Set<ExclusiveResource>getExclusiveResources()Get the set of resources required to execute this node.Node.ExecutionModegetExecutionMode()Get the preferred of execution mode for parallel execution of this node.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.Set<TestTag>getTags()Get the set of tags associated with this descriptor.Class<?>getTestClass()MethodgetTestMethod()TestDescriptor.TypegetType()Determine theTestDescriptor.Typeof this descriptor.protected voidinvokeTestMethod(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)protected ExtensionRegistrypopulateNewExtensionRegistry(JupiterEngineExecutionContext context)JupiterEngineExecutionContextprepare(JupiterEngineExecutionContext context)Must be overridden and return a new context so cleanUp() does not accidentally close the parent context.-
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 org.junit.jupiter.engine.descriptor.JupiterTestDescriptor
cleanUp, determineDisplayName, executeAndMaskThrowable, getExclusiveResources, getExecutionMode, getTags, shouldBeSkipped
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.junit.platform.engine.TestDescriptor
accept, getDescendants, isContainer, isRoot, isTest, mayRegisterTests, prune
-
-
-
-
Method Detail
-
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) throws Exception
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- Throws:
Exception- See Also:
Node.cleanUp(EngineExecutionContext)
-
populateNewExtensionRegistry
protected ExtensionRegistry populateNewExtensionRegistry(JupiterEngineExecutionContext context)
-
execute
public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor) throws Exception
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.- 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
- Throws:
Exception- See Also:
Node.before(C),Node.after(C)
-
invokeTestMethod
protected void invokeTestMethod(JupiterEngineExecutionContext context, Node.DynamicTestExecutor dynamicTestExecutor)
-
getTags
public final Set<TestTag> getTags()
Description copied from interface:TestDescriptorGet the set of tags associated with this descriptor.- Specified by:
getTagsin interfaceTestDescriptor- Overrides:
getTagsin classAbstractTestDescriptor- Returns:
- the set of tags associated with this descriptor; never
nullbut potentially empty - See Also:
TestTag
-
getExclusiveResources
public Set<ExclusiveResource> getExclusiveResources()
Description copied from interface:NodeGet the set of resources required to execute this node.- Returns:
- the set of resources required by this node; never
nullbut potentially empty - See Also:
ExclusiveResource
-
getExecutionMode
public Node.ExecutionMode getExecutionMode()
Description copied from interface:NodeGet the preferred of execution mode for parallel execution of this node.- Returns:
- the preferred execution mode of this node; never
null - See Also:
Node.ExecutionMode
-
getTestClass
public final Class<?> getTestClass()
-
getTestMethod
public final Method getTestMethod()
-
getLegacyReportingName
public 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
-
-