TestDescriptorEngineDescriptor, JupiterTestDescriptor, VintageTestDescriptor@API(status=STABLE, since="1.0") public abstract class AbstractTestDescriptor extends java.lang.Object implements TestDescriptor
TestDescriptor that may be used by
custom TestEngines.
Subclasses should provide a TestSource in their constructor, if
possible, and override getTags(), if appropriate.
TestDescriptor.Type, TestDescriptor.Visitor| Modifier and Type | Field | Description |
|---|---|---|
protected java.util.Set<TestDescriptor> |
children |
The synchronized set of children associated with this
TestDescriptor. |
| Modifier | Constructor | Description |
|---|---|---|
protected |
AbstractTestDescriptor(UniqueId uniqueId,
java.lang.String displayName) |
Create a new
AbstractTestDescriptor with the supplied
UniqueId and display name. |
protected |
AbstractTestDescriptor(UniqueId uniqueId,
java.lang.String displayName,
TestSource source) |
Create a new
AbstractTestDescriptor with the supplied
UniqueId, display name, and source. |
| Modifier and Type | Method | 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 immutable 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.
|
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitaccept, containsTests, getDescendants, getLegacyReportingName, getType, isContainer, isRoot, isTest, mayRegisterTests, pruneprotected final java.util.Set<TestDescriptor> children
TestDescriptor.
This set is used in methods such as addChild(TestDescriptor),
removeChild(TestDescriptor), removeFromHierarchy(), and
findByUniqueId(UniqueId), and an immutable copy of this set is
returned by getChildren().
If a subclass overrides any of the methods related to children, this set should be used instead of a set local to the subclass.
protected AbstractTestDescriptor(UniqueId uniqueId, java.lang.String displayName)
AbstractTestDescriptor with the supplied
UniqueId and display name.uniqueId - the unique ID of this TestDescriptor; never
nulldisplayName - the display name for this TestDescriptor;
never null or blankAbstractTestDescriptor(UniqueId, String, TestSource)protected AbstractTestDescriptor(UniqueId uniqueId, java.lang.String displayName, TestSource source)
AbstractTestDescriptor with the supplied
UniqueId, display name, and source.uniqueId - the unique ID of this TestDescriptor; never
nulldisplayName - the display name for this TestDescriptor;
never null or blanksource - the source of the test or container described by this
TestDescriptor; can be nullAbstractTestDescriptor(UniqueId, String)public final UniqueId getUniqueId()
TestDescriptorUniqueness must be guaranteed across an entire test plan, regardless of how many engines are used behind the scenes.
getUniqueId in interface TestDescriptorUniqueId for this descriptor; never nullpublic final java.lang.String getDisplayName()
TestDescriptorA 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 TestDescriptornull or blankTestDescriptor.getSource()public java.util.Set<TestTag> getTags()
TestDescriptorgetTags in interface TestDescriptornull
but potentially emptyTestTagpublic java.util.Optional<TestSource> getSource()
TestDescriptorgetSource in interface TestDescriptorTestSourcepublic final java.util.Optional<TestDescriptor> getParent()
TestDescriptorgetParent in interface TestDescriptorpublic final void setParent(TestDescriptor parent)
TestDescriptorsetParent in interface TestDescriptorparent - the new parent of this descriptor; may be null.public final java.util.Set<? extends TestDescriptor> getChildren()
TestDescriptorgetChildren in interface TestDescriptornull
nor mutable, but potentially emptyTestDescriptor.getDescendants()public void addChild(TestDescriptor child)
TestDescriptoraddChild in interface TestDescriptorchild - the child to add to this descriptor; never nullpublic void removeChild(TestDescriptor child)
TestDescriptorremoveChild in interface TestDescriptorchild - the child to remove from this descriptor; never
nullpublic void removeFromHierarchy()
TestDescriptorIf 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 TestDescriptorpublic java.util.Optional<? extends TestDescriptor> findByUniqueId(UniqueId uniqueId)
TestDescriptorThe search algorithm begins with this descriptor and then searches through its descendants.
findByUniqueId in interface TestDescriptoruniqueId - the UniqueId to search for; never nullpublic final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object