@API(value=Experimental) public abstract class AbstractTestDescriptor extends java.lang.Object implements TestDescriptor
TestDescriptor
that may be used by
custom TestEngines
.
Subclasses should call setSource(org.junit.platform.engine.TestSource)
in their constructor, if
possible, and override getTags()
, if appropriate.
TestDescriptor.Visitor
Modifier | Constructor and Description |
---|---|
protected |
AbstractTestDescriptor(UniqueId uniqueId,
java.lang.String displayName)
Create a new
AbstractTestDescriptor with the supplied
UniqueId and display name. |
Modifier and Type | Method and Description |
---|---|
void |
addChild(TestDescriptor child)
Add a child to this descriptor.
|
boolean |
equals(java.lang.Object other) |
java.util.Optional<? extends TestDescriptor> |
findByUniqueId(UniqueId uniqueId)
Find the descriptor with the supplied unique ID.
|
java.util.Set<? extends TestDescriptor> |
getChildren()
Get the set of children of this descriptor.
|
java.lang.String |
getDisplayName()
Get the display name for this descriptor.
|
java.util.Optional<TestDescriptor> |
getParent()
Get the parent of this descriptor, if available.
|
java.util.Optional<TestSource> |
getSource()
Get the source of the test or container described
by this descriptor, if available.
|
java.util.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.
|
protected void |
setSource(TestSource source) |
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
accept, getAllDescendants, hasTests, isContainer, isRoot, isTest
protected AbstractTestDescriptor(UniqueId uniqueId, java.lang.String displayName)
AbstractTestDescriptor
with the supplied
UniqueId
and display name.uniqueId
- the unique ID of this TestDescriptor
; never
null
displayName
- the display name for this TestDescriptor
;
never null
or blankpublic final UniqueId getUniqueId()
TestDescriptor
Uniqueness must be guaranteed across an entire test plan, regardless of how many engines are used behind the scenes.
getUniqueId
in interface TestDescriptor
UniqueId
for this descriptor; never null
public final java.lang.String getDisplayName()
TestDescriptor
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.
getDisplayName
in interface TestDescriptor
null
or blankTestDescriptor.getSource()
public java.util.Optional<TestDescriptor> getParent()
TestDescriptor
getParent
in interface TestDescriptor
public final void setParent(TestDescriptor parent)
TestDescriptor
setParent
in interface TestDescriptor
parent
- the new parent of this descriptor; may be null
.public void removeChild(TestDescriptor child)
TestDescriptor
removeChild
in interface TestDescriptor
child
- the child to remove from this descriptor; never
null
public void removeFromHierarchy()
TestDescriptor
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.
removeFromHierarchy
in interface TestDescriptor
public java.util.Optional<? extends TestDescriptor> findByUniqueId(UniqueId uniqueId)
TestDescriptor
The search algorithm begins with this descriptor and then searches through its descendants.
findByUniqueId
in interface TestDescriptor
uniqueId
- the UniqueId
to search for; never null
public void addChild(TestDescriptor child)
TestDescriptor
addChild
in interface TestDescriptor
child
- the child to add to this descriptor; never null
public final java.util.Set<? extends TestDescriptor> getChildren()
TestDescriptor
getChildren
in interface TestDescriptor
null
but potentially emptyTestDescriptor.getAllDescendants()
protected final void setSource(TestSource source)
public java.util.Set<TestTag> getTags()
TestDescriptor
getTags
in interface TestDescriptor
null
but potentially emptyTestTag
public java.util.Optional<TestSource> getSource()
TestDescriptor
getSource
in interface TestDescriptor
TestSource
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object