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 ofTestDescriptorthat may be used by customTestEngines.Subclasses should provide a
TestSourcein 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>childrenThe synchronized set of children associated with thisTestDescriptor.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTestDescriptor(UniqueId uniqueId, String displayName)Create a newAbstractTestDescriptorwith the suppliedUniqueIdand display name.protectedAbstractTestDescriptor(UniqueId uniqueId, String displayName, TestSource source)Create a newAbstractTestDescriptorwith the suppliedUniqueId, display name, and source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(TestDescriptor child)Add a child to this descriptor.booleanequals(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.StringgetDisplayName()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.UniqueIdgetUniqueId()Get the unique identifier (UID) for this descriptor.inthashCode()voidremoveChild(TestDescriptor child)Remove a child from this descriptor.voidremoveFromHierarchy()Remove this non-root descriptor from its parent and remove all the children from this descriptor.voidsetParent(TestDescriptor parent)Set the parent of this descriptor.StringtoString()-
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 newAbstractTestDescriptorwith the suppliedUniqueIdand display name.- Parameters:
uniqueId- the unique ID of thisTestDescriptor; nevernulldisplayName- the display name for thisTestDescriptor; nevernullor blank- See Also:
AbstractTestDescriptor(UniqueId, String, TestSource)
-
AbstractTestDescriptor
protected AbstractTestDescriptor(UniqueId uniqueId, String displayName, TestSource source)
Create a newAbstractTestDescriptorwith the suppliedUniqueId, display name, and source.- Parameters:
uniqueId- the unique ID of thisTestDescriptor; nevernulldisplayName- the display name for thisTestDescriptor; nevernullor 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:TestDescriptorGet 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:
getUniqueIdin interfaceTestDescriptor- Returns:
- the
UniqueIdfor this descriptor; nevernull
-
getDisplayName
public final String getDisplayName()
Description copied from interface:TestDescriptorGet 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
TestEnginesor potentially by end users as well. Consequently, display names should never be parsed; rather, they should be used for display purposes only.- Specified by:
getDisplayNamein interfaceTestDescriptor- Returns:
- the display name for this descriptor; never
nullor blank - See Also:
TestDescriptor.getSource()
-
getTags
public Set<TestTag> getTags()
Description copied from interface:TestDescriptorGet the set of tags associated with this descriptor.- Specified by:
getTagsin interfaceTestDescriptor- Returns:
- the set of tags associated with this descriptor; never
nullbut potentially empty - See Also:
TestTag
-
getSource
public Optional<TestSource> getSource()
Description copied from interface:TestDescriptorGet the source of the test or container described by this descriptor, if available.- Specified by:
getSourcein interfaceTestDescriptor- See Also:
TestSource
-
getParent
public final Optional<TestDescriptor> getParent()
Description copied from interface:TestDescriptorGet the parent of this descriptor, if available.- Specified by:
getParentin interfaceTestDescriptor
-
setParent
public final void setParent(TestDescriptor parent)
Description copied from interface:TestDescriptorSet the parent of this descriptor.- Specified by:
setParentin interfaceTestDescriptor- Parameters:
parent- the new parent of this descriptor; may benull.
-
getChildren
public final Set<? extends TestDescriptor> getChildren()
Description copied from interface:TestDescriptorGet the immutable set of children of this descriptor.- Specified by:
getChildrenin interfaceTestDescriptor- Returns:
- the set of children of this descriptor; neither
nullnor mutable, but potentially empty - See Also:
TestDescriptor.getDescendants()
-
addChild
public void addChild(TestDescriptor child)
Description copied from interface:TestDescriptorAdd a child to this descriptor.- Specified by:
addChildin interfaceTestDescriptor- Parameters:
child- the child to add to this descriptor; nevernull
-
removeChild
public void removeChild(TestDescriptor child)
Description copied from interface:TestDescriptorRemove a child from this descriptor.- Specified by:
removeChildin interfaceTestDescriptor- Parameters:
child- the child to remove from this descriptor; nevernull
-
removeFromHierarchy
public void removeFromHierarchy()
Description copied from interface:TestDescriptorRemove 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
JUnitExceptionexplaining that a root cannot be removed from the hierarchy.- Specified by:
removeFromHierarchyin interfaceTestDescriptor
-
findByUniqueId
public Optional<? extends TestDescriptor> findByUniqueId(UniqueId uniqueId)
Description copied from interface:TestDescriptorFind the descriptor with the supplied unique ID.The search algorithm begins with this descriptor and then searches through its descendants.
- Specified by:
findByUniqueIdin interfaceTestDescriptor- Parameters:
uniqueId- theUniqueIdto search for; nevernull
-
-