Class AbstractTestDescriptor
- java.lang.Object
-
- org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
-
- All Implemented Interfaces:
TestDescriptor
- Direct Known Subclasses:
EngineDescriptor
,JupiterTestDescriptor
,VintageTestDescriptor
@API(status=STABLE, since="1.0") public abstract class AbstractTestDescriptor extends Object implements TestDescriptor
Abstract base implementation ofTestDescriptor
that may be used by customTestEngines
.Subclasses should provide a
TestSource
in their constructor, if possible, and overridegetTags()
, 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
Fields Modifier and Type Field Description protected Set<TestDescriptor>
children
The synchronized set of children associated with thisTestDescriptor
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(TestDescriptor child)
Add a child to this descriptor.boolean
equals(Object other)
Optional<? extends TestDescriptor>
findByUniqueId(UniqueId uniqueId)
Find the descriptor with the supplied unique ID.Set<? extends TestDescriptor>
getChildren()
Get the immutable set of children of this descriptor.String
getDisplayName()
Get the display name for this descriptor.Optional<TestDescriptor>
getParent()
Get the parent of this descriptor, if available.Optional<TestSource>
getSource()
Get the source of the test or container described by this descriptor, if available.Set<TestTag>
getTags()
Get the set of tags associated with this descriptor.UniqueId
getUniqueId()
Get the unique identifier (UID) for this descriptor.int
hashCode()
void
removeChild(TestDescriptor child)
Remove a child from this descriptor.void
removeFromHierarchy()
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.String
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 Detail
-
children
protected final Set<TestDescriptor> 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 Detail
-
AbstractTestDescriptor
protected AbstractTestDescriptor(UniqueId uniqueId, String displayName)
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
protected AbstractTestDescriptor(UniqueId uniqueId, String displayName, TestSource source)
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 Detail
-
getUniqueId
public final UniqueId 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
public final String 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
public Set<TestTag> 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
public Optional<TestSource> 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
public final Optional<TestDescriptor> getParent()
Description copied from interface:TestDescriptor
Get the parent of this descriptor, if available.- Specified by:
getParent
in interfaceTestDescriptor
-
setParent
public final void setParent(TestDescriptor parent)
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
public final Set<? extends TestDescriptor> 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
public void addChild(TestDescriptor child)
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
public void removeChild(TestDescriptor child)
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
public Optional<? extends TestDescriptor> findByUniqueId(UniqueId uniqueId)
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
-
-