@API(status=STABLE, since="1.0") public abstract class AbstractTestDescriptor extends 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 and Description |
---|---|
protected Set<TestDescriptor> |
children
The synchronized set of children associated with this
TestDescriptor . |
Modifier | Constructor and Description |
---|---|
protected |
AbstractTestDescriptor(UniqueId uniqueId,
String displayName)
Create a new
AbstractTestDescriptor with the supplied
UniqueId and display name. |
protected |
AbstractTestDescriptor(UniqueId uniqueId,
String displayName,
TestSource source)
Create a new
AbstractTestDescriptor with the supplied
UniqueId , display name, and source. |
Modifier and Type | Method and 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() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
accept, containsTests, getDescendants, getLegacyReportingName, getType, isContainer, isRoot, isTest, mayRegisterTests, prune
protected final 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, 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 blankAbstractTestDescriptor(UniqueId, String, TestSource)
protected AbstractTestDescriptor(UniqueId uniqueId, String displayName, TestSource source)
AbstractTestDescriptor
with the supplied
UniqueId
, display name, and source.uniqueId
- the unique ID of this TestDescriptor
; never
null
displayName
- the display name for this TestDescriptor
;
never null
or blanksource
- the source of the test or container described by this
TestDescriptor
; can be null
AbstractTestDescriptor(UniqueId, String)
public 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 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 Set<TestTag> getTags()
TestDescriptor
getTags
in interface TestDescriptor
null
but potentially emptyTestTag
public Optional<TestSource> getSource()
TestDescriptor
getSource
in interface TestDescriptor
TestSource
public final 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 final Set<? extends TestDescriptor> getChildren()
TestDescriptor
getChildren
in interface TestDescriptor
null
nor mutable, but potentially emptyTestDescriptor.getDescendants()
public void addChild(TestDescriptor child)
TestDescriptor
addChild
in interface TestDescriptor
child
- the child to add to this descriptor; never 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 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