Top Description Fields Constructors Methods
org.junit.platform.engine.support.descriptor

public abstract Class AbstractTestDescriptor

extends Object
implements TestDescriptor
Class Inheritance
All Implemented Interfaces
org.junit.platform.engine.TestDescriptor
Known Direct Subclasses
org.junit.platform.engine.support.descriptor.EngineDescriptor
Annotations
@API
status:STABLE
since:1.0
Static Imports
java.util.Collections.emptySet, org.apiguardian.api.API.Status.STABLE

Abstract base implementation of TestDescriptor that may be used by custom TestEngines.

Subclasses should provide a TestSource in their constructor, if possible, and override getTags(), if appropriate.

Since
1.0

Field Summary

Modifier and TypeField and Description
protected final Set<TestDescriptor>
children

The synchronized set of children associated with this TestDescriptor.

private final String
private @Nullable TestDescriptor
private final @Nullable TestSource
private static final String
UNICODE_REPLACEMENT_CHARACTER

The Unicode replacement character, often displayed as a black diamond with a white question mark in it:

private final UniqueId

Constructor Summary

AccessConstructor and Description
protected
AbstractTestDescriptor(UniqueId
the unique ID of this TestDescriptor; never null
uniqueId
,
String
the display name for this TestDescriptor; never null or blank
displayName
)

Create a new AbstractTestDescriptor with the supplied UniqueId and display name.

protected
AbstractTestDescriptor(UniqueId
the unique ID of this TestDescriptor; never null
uniqueId
,
String
the display name for this TestDescriptor; never null or blank
displayName
,
@Nullable TestSource
the source of the test or container described by this TestDescriptor; can be null
source
)

Create a new AbstractTestDescriptor with the supplied UniqueId, display name, and source.

Method Summary

Modifier and TypeMethod and Description
public void
addChild(TestDescriptor child)

Implements org.junit.platform.engine.TestDescriptor.addChild.

Add a child to this descriptor.

public final boolean
equals(Object other)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Optional<? extends TestDescriptor>
findByUniqueId(UniqueId uniqueId)

Implements org.junit.platform.engine.TestDescriptor.findByUniqueId.

Find the descriptor with the supplied unique ID.

The search algorithm begins with this descriptor and then searches through its descendants.

public final Set<? extends TestDescriptor>
getChildren()

Implements org.junit.platform.engine.TestDescriptor.getChildren.

Get the immutable set of children of this descriptor.

public final String
getDisplayName()

Implements org.junit.platform.engine.TestDescriptor.getDisplayName.

Get the display name for this descriptor.

public final Optional<TestDescriptor>
getParent()

Implements org.junit.platform.engine.TestDescriptor.getParent.

Get the parent of this descriptor, if available.

public Optional<TestSource>
getSource()

Implements org.junit.platform.engine.TestDescriptor.getSource.

Get the source of the test or container described by this descriptor, if available.

public Set<TestTag>
getTags()

Implements org.junit.platform.engine.TestDescriptor.getTags.

Get the set of tags associated with this descriptor.

public final UniqueId
getUniqueId()

Implements org.junit.platform.engine.TestDescriptor.getUniqueId.

Get the unique identifier (UID) for this descriptor.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
orderChildren(UnaryOperator<List<TestDescriptor>> orderer)

Overrides default org.junit.platform.engine.TestDescriptor.orderChildren.

Order the children of this descriptor.

public void
removeChild(TestDescriptor child)

Implements org.junit.platform.engine.TestDescriptor.removeChild.

Remove a child from this descriptor.

public void
removeFromHierarchy()

Implements org.junit.platform.engine.TestDescriptor.removeFromHierarchy.

Remove this non-root descriptor from its parent and remove all the children from this descriptor.

private static String
private static String
public final void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

childrenback to summary
protected final Set<TestDescriptor> children

The synchronized set of children associated with this 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.

displayNameback to summary
private final String displayName
parentback to summary
private @Nullable TestDescriptor parent
sourceback to summary
private final @Nullable TestSource source
UNICODE_REPLACEMENT_CHARACTERback to summary
private static final String UNICODE_REPLACEMENT_CHARACTER

The Unicode replacement character, often displayed as a black diamond with a white question mark in it:

uniqueIdback to summary
private final UniqueId uniqueId

Constructor Detail

AbstractTestDescriptorback to summary
protected AbstractTestDescriptor(UniqueId uniqueId, String displayName)

Create a new AbstractTestDescriptor with the supplied UniqueId and display name.

As of JUnit 6.0, ISO control characters in the provided display name will be replaced. See AbstractTestDescriptor(UniqueId, String, TestSource) for details.

Parameters
uniqueId:UniqueId

the unique ID of this TestDescriptor; never null

displayName:String

the display name for this TestDescriptor; never null or blank

See Also
AbstractTestDescriptor(UniqueId, String, TestSource)
AbstractTestDescriptorback to summary
protected AbstractTestDescriptor(UniqueId uniqueId, String displayName, @Nullable TestSource source)

Create a new AbstractTestDescriptor with the supplied UniqueId, display name, and source.

As of JUnit 6.0, ISO control characters in the provided display name will be replaced according to the following table.

Control Character Replacement
Original Replacement Description
\r <CR> Textual representation of a carriage return
\n <LF> Textual representation of a line feed
Other control character � Unicode replacement character (U+FFFD)
Parameters
uniqueId:UniqueId

the unique ID of this TestDescriptor; never null

displayName:String

the display name for this TestDescriptor; never null or blank

source:@Nullable TestSource

the source of the test or container described by this TestDescriptor; can be null

See Also
AbstractTestDescriptor(UniqueId, String)

Method Detail

addChildback to summary
public void addChild(TestDescriptor child)

Implements org.junit.platform.engine.TestDescriptor.addChild.

Doc from org.junit.platform.engine.TestDescriptor.addChild.

Add a child to this descriptor.

Annotations
@Override
equalsback to summary
public final boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
@SuppressWarnings:EqualsGetClass
findByUniqueIdback to summary
public Optional<? extends TestDescriptor> findByUniqueId(UniqueId uniqueId)

Implements org.junit.platform.engine.TestDescriptor.findByUniqueId.

Doc from org.junit.platform.engine.TestDescriptor.findByUniqueId.

Find the descriptor with the supplied unique ID.

The search algorithm begins with this descriptor and then searches through its descendants.

Annotations
@Override
getChildrenback to summary
public final Set<? extends TestDescriptor> getChildren()

Implements org.junit.platform.engine.TestDescriptor.getChildren.

Doc from org.junit.platform.engine.TestDescriptor.getChildren.

Get the immutable set of children of this descriptor.

Annotations
@Override
getDisplayNameback to summary
public final String getDisplayName()

Implements org.junit.platform.engine.TestDescriptor.getDisplayName.

Doc from org.junit.platform.engine.TestDescriptor.getDisplayName.

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.

Annotations
@Override
getParentback to summary
public final Optional<TestDescriptor> getParent()

Implements org.junit.platform.engine.TestDescriptor.getParent.

Doc from org.junit.platform.engine.TestDescriptor.getParent.

Get the parent of this descriptor, if available.

Annotations
@Override
getSourceback to summary
public Optional<TestSource> getSource()

Implements org.junit.platform.engine.TestDescriptor.getSource.

Doc from org.junit.platform.engine.TestDescriptor.getSource.

Get the source of the test or container described by this descriptor, if available.

Annotations
@Override
getTagsback to summary
public Set<TestTag> getTags()

Implements org.junit.platform.engine.TestDescriptor.getTags.

Doc from org.junit.platform.engine.TestDescriptor.getTags.

Get the set of tags associated with this descriptor.

Annotations
@Override
getUniqueIdback to summary
public final UniqueId getUniqueId()

Implements org.junit.platform.engine.TestDescriptor.getUniqueId.

Doc from org.junit.platform.engine.TestDescriptor.getUniqueId.

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.

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
orderChildrenback to summary
public void orderChildren(UnaryOperator<List<TestDescriptor>> orderer)

Overrides default org.junit.platform.engine.TestDescriptor.orderChildren.

Doc from org.junit.platform.engine.TestDescriptor.orderChildren.

Order the children of this descriptor.

The orderer is provided a modifiable list of child test descriptors of this test descriptor; never null. The orderer must return a list containing the same descriptors in any order; potentially the same list, but never null. If descriptors are added or removed, an exception is thrown.

Annotations
@Override
removeChildback to summary
public void removeChild(TestDescriptor child)

Implements org.junit.platform.engine.TestDescriptor.removeChild.

Doc from org.junit.platform.engine.TestDescriptor.removeChild.

Remove a child from this descriptor.

Annotations
@Override
removeFromHierarchyback to summary
public void removeFromHierarchy()

Implements org.junit.platform.engine.TestDescriptor.removeFromHierarchy.

Doc from org.junit.platform.engine.TestDescriptor.removeFromHierarchy.

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.

Annotations
@Override
replaceControlCharacterback to summary
private static String replaceControlCharacter(char ch)
replaceControlCharactersback to summary
private static String replaceControlCharacters(String text)
setParentback to summary
public final void setParent(@Nullable TestDescriptor parent)
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override