Class AbstractTestDescriptor
- All Implemented Interfaces:
TestDescriptor
- Direct Known Subclasses:
EngineDescriptor
,JupiterTestDescriptor
,VintageTestDescriptor
TestDescriptor
that may be used by
custom TestEngines
.
Subclasses should provide a TestSource
in their constructor, if
possible, and override getTags()
, if appropriate.
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.platform.engine.TestDescriptor
TestDescriptor.Type, TestDescriptor.Visitor
-
Field Summary
Modifier and TypeFieldDescriptionprotected Set<TestDescriptor>
The synchronized set of children associated with thisTestDescriptor
. -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractTestDescriptor(UniqueId uniqueId, String displayName)
Create a newAbstractTestDescriptor
with the suppliedUniqueId
and display name.protected
AbstractTestDescriptor(UniqueId uniqueId, String displayName, TestSource source)
Create a newAbstractTestDescriptor
with the suppliedUniqueId
, display name, and source. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild(TestDescriptor child)
Add a child to this descriptor.boolean
Optional<? extends TestDescriptor>
findByUniqueId(UniqueId uniqueId)
Find the descriptor with the supplied unique ID.Set<? extends TestDescriptor>
Get the immutable set of children of this descriptor.Get the display name for this descriptor.Get the parent of this descriptor, if available.Get the source of the test or container described by this descriptor, if available.getTags()
Get the set of tags associated with this descriptor.Get the unique identifier (UID) for this descriptor.int
hashCode()
void
removeChild(TestDescriptor child)
Remove a child from this descriptor.void
Remove this non-root descriptor from its parent and remove all the children from this descriptor.void
setParent(TestDescriptor parent)
Set the parent of this descriptor.toString()
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, getLegacyReportingName, getType, isContainer, isRoot, isTest, mayRegisterTests, prune
-
Field Details
-
children
The synchronized set of children associated with thisTestDescriptor
.This set is used in methods such as
addChild(TestDescriptor)
,removeChild(TestDescriptor)
,removeFromHierarchy()
, andfindByUniqueId(UniqueId)
, and an immutable copy of this set is returned bygetChildren()
.If a subclass overrides any of the methods related to children, this set should be used instead of a set local to the subclass.
-
-
Constructor Details
-
AbstractTestDescriptor
Create a newAbstractTestDescriptor
with the suppliedUniqueId
and display name.- Parameters:
uniqueId
- the unique ID of thisTestDescriptor
; nevernull
displayName
- the display name for thisTestDescriptor
; nevernull
or blank- See Also:
AbstractTestDescriptor(UniqueId, String, TestSource)
-
AbstractTestDescriptor
Create a newAbstractTestDescriptor
with the suppliedUniqueId
, display name, and source.- Parameters:
uniqueId
- the unique ID of thisTestDescriptor
; nevernull
displayName
- the display name for thisTestDescriptor
; nevernull
or blanksource
- the source of the test or container described by thisTestDescriptor
; can benull
- See Also:
AbstractTestDescriptor(UniqueId, String)
-
-
Method Details
-
getUniqueId
Description copied from interface:TestDescriptor
Get the unique identifier (UID) for this descriptor.Uniqueness must be guaranteed across an entire test plan, regardless of how many engines are used behind the scenes.
- Specified by:
getUniqueId
in interfaceTestDescriptor
- Returns:
- the
UniqueId
for this descriptor; nevernull
-
getDisplayName
Description copied from interface:TestDescriptor
Get the display name for this descriptor.A display name is a human-readable name for a test or container that is typically used for test reporting in IDEs and build tools. Display names may contain spaces, special characters, and emoji, and the format may be customized by
TestEngines
or potentially by end users as well. Consequently, display names should never be parsed; rather, they should be used for display purposes only.- Specified by:
getDisplayName
in interfaceTestDescriptor
- Returns:
- the display name for this descriptor; never
null
or blank - See Also:
TestDescriptor.getSource()
-
getTags
Description copied from interface:TestDescriptor
Get the set of tags associated with this descriptor.- Specified by:
getTags
in interfaceTestDescriptor
- Returns:
- the set of tags associated with this descriptor; never
null
but potentially empty - See Also:
TestTag
-
getSource
Description copied from interface:TestDescriptor
Get the source of the test or container described by this descriptor, if available.- Specified by:
getSource
in interfaceTestDescriptor
- See Also:
TestSource
-
getParent
Description copied from interface:TestDescriptor
Get the parent of this descriptor, if available.- Specified by:
getParent
in interfaceTestDescriptor
-
setParent
Description copied from interface:TestDescriptor
Set the parent of this descriptor.- Specified by:
setParent
in interfaceTestDescriptor
- Parameters:
parent
- the new parent of this descriptor; may benull
.
-
getChildren
Description copied from interface:TestDescriptor
Get the immutable set of children of this descriptor.- Specified by:
getChildren
in interfaceTestDescriptor
- Returns:
- the set of children of this descriptor; neither
null
nor mutable, but potentially empty - See Also:
TestDescriptor.getDescendants()
-
addChild
Description copied from interface:TestDescriptor
Add a child to this descriptor.- Specified by:
addChild
in interfaceTestDescriptor
- Parameters:
child
- the child to add to this descriptor; nevernull
-
removeChild
Description copied from interface:TestDescriptor
Remove a child from this descriptor.- Specified by:
removeChild
in interfaceTestDescriptor
- Parameters:
child
- the child to remove from this descriptor; nevernull
-
removeFromHierarchy
public void removeFromHierarchy()Description copied from interface:TestDescriptor
Remove this non-root descriptor from its parent and remove all the children from this descriptor.If this method is invoked on a root descriptor, this method must throw a
JUnitException
explaining that a root cannot be removed from the hierarchy.- Specified by:
removeFromHierarchy
in interfaceTestDescriptor
-
findByUniqueId
Description copied from interface:TestDescriptor
Find the descriptor with the supplied unique ID.The search algorithm begins with this descriptor and then searches through its descendants.
- Specified by:
findByUniqueId
in interfaceTestDescriptor
- Parameters:
uniqueId
- theUniqueId
to search for; nevernull
-
hashCode
public final int hashCode() -
equals
-
toString
-