Top Description Inners Methods
org.junit.platform.engine

public Interface TestDescriptor

Known Direct Implementers
org.junit.platform.engine.support.descriptor.AbstractTestDescriptor
Annotations
@API
status:STABLE
since:1.0
Static Imports
org.apiguardian.api.API.Status.STABLE

Mutable descriptor for a test or container that has been discovered by a TestEngine.
Since
1.0
See Also
TestEngine

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static interface
TestDescriptor.Visitor

Visitor for the tree-like TestDescriptor structure.

Method Summary

Modifier and TypeMethod and Description
public default void
accept(TestDescriptor.Visitor
the Visitor to accept; never null
visitor
)

Accept a Visitor to the subtree starting with this descriptor.

public void
addChild(TestDescriptor
the child to add to this descriptor; never null
descriptor
)

Add a child to this descriptor.

public static boolean

Returns:

true if the descriptor is a test, contains tests, or may later register tests dynamically
containsTests
(TestDescriptor
the TestDescriptor to check for tests; never null
testDescriptor
)

Determine if the supplied descriptor (or any of its descendants) is a test or may potentially register tests dynamically.

public Optional<? extends TestDescriptor>
findByUniqueId(UniqueId
the UniqueId to search for; never null
uniqueId
)

Find the descriptor with the supplied unique ID.

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

public default Set<? extends TestDescriptor>
getAncestors()

Get the immutable set of all ancestors of this descriptor.

public Set<? extends TestDescriptor>

Returns:

the set of children of this descriptor; neither null nor mutable, but potentially empty
getChildren
()

Get the immutable set of children of this descriptor.

public default Set<? extends TestDescriptor>
getDescendants()

Get the immutable set of all descendants of this descriptor.

public String

Returns:

the display name for this descriptor; never null or blank
getDisplayName
()

Get the display name for this descriptor.

public default String

Returns:

the legacy reporting name; never null or blank
getLegacyReportingName
()

Get the name of this descriptor in a format that is suitable for legacy reporting infrastructure — for example, for reporting systems built on the Ant-based XML reporting format for JUnit 4.

public Optional<TestDescriptor>
getParent()

Get the parent of this descriptor, if available.

public Optional<TestSource>
getSource()

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

public Set<TestTag>

Returns:

the set of tags associated with this descriptor; never null but potentially empty
getTags
()

Get the set of tags associated with this descriptor.

public TestDescriptor.Type

Returns:

the descriptor type; never null.
getType
()

Determine the Type of this descriptor.

public UniqueId

Returns:

the UniqueId for this descriptor; never null
getUniqueId
()

Get the unique identifier (UID) for this descriptor.

public default boolean
isContainer()

Determine if this descriptor describes a container.

public default boolean
isRoot()

Determine if this descriptor is a root descriptor.

public default boolean
isTest()

Determine if this descriptor describes a test.

public default boolean
mayRegisterTests()

Determine if this descriptor may register dynamic tests during execution.

public default void
prune()

Remove this descriptor from the hierarchy unless it is a root or contains tests.

public void
removeChild(TestDescriptor
the child to remove from this descriptor; never null
descriptor
)

Remove a child from this descriptor.

public void
removeFromHierarchy()

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

public void
setParent(TestDescriptor
the new parent of this descriptor; may be null.
parent
)

Set the parent of this descriptor.

Method Detail

acceptback to summary
public default void accept(TestDescriptor.Visitor visitor)

Accept a Visitor to the subtree starting with this descriptor.

Parameters
visitor:TestDescriptor.Visitor

the Visitor to accept; never null

addChildback to summary
public void addChild(TestDescriptor descriptor)

Add a child to this descriptor.

Parameters
descriptor:TestDescriptor

the child to add to this descriptor; never null

containsTestsback to summary
public static boolean containsTests(TestDescriptor testDescriptor)

Determine if the supplied descriptor (or any of its descendants) is a test or may potentially register tests dynamically.

Parameters
testDescriptor:TestDescriptor

the TestDescriptor to check for tests; never null

Returns:boolean

true if the descriptor is a test, contains tests, or may later register tests dynamically

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

Find the descriptor with the supplied unique ID.

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

Parameters
uniqueId:UniqueId

the UniqueId to search for; never null

getAncestorsback to summary
public default Set<? extends TestDescriptor> getAncestors()

Get the immutable set of all ancestors of this descriptor.

An ancestor is the parent of this descriptor or the parent of one of its parents, recursively.

Annotations
@API
status:STABLE
since:1.10
See Also
getParent()
getChildrenback to summary
public Set<? extends TestDescriptor> getChildren()

Get the immutable set of children of this descriptor.

Returns:Set<? extends TestDescriptor>

the set of children of this descriptor; neither null nor mutable, but potentially empty

See Also
getDescendants()
getDescendantsback to summary
public default Set<? extends TestDescriptor> getDescendants()

Get the immutable set of all descendants of this descriptor.

A descendant is a child of this descriptor or a child of one of its children, recursively.

See Also
getChildren()
getDisplayNameback to summary
public String 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.

Returns:String

the display name for this descriptor; never null or blank

See Also
getSource()
getLegacyReportingNameback to summary
public default String getLegacyReportingName()

Get the name of this descriptor in a format that is suitable for legacy reporting infrastructure — for example, for reporting systems built on the Ant-based XML reporting format for JUnit 4.

The default implementation delegates to getDisplayName().

Returns:String

the legacy reporting name; never null or blank

getParentback to summary
public Optional<TestDescriptor> getParent()

Get the parent of this descriptor, if available.

getSourceback to summary
public Optional<TestSource> getSource()

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

See Also
TestSource
getTagsback to summary
public Set<TestTag> getTags()

Get the set of tags associated with this descriptor.

Returns:Set<TestTag>

the set of tags associated with this descriptor; never null but potentially empty

See Also
TestTag
getTypeback to summary
public TestDescriptor.Type getType()

Determine the Type of this descriptor.

Returns:TestDescriptor.Type

the descriptor type; never null.

See Also
isContainer(), isTest()
getUniqueIdback to summary
public UniqueId 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.

Returns:UniqueId

the UniqueId for this descriptor; never null

isContainerback to summary
public default boolean isContainer()

Determine if this descriptor describes a container.

The default implementation delegates to Type#isContainer().

isRootback to summary
public default boolean isRoot()

Determine if this descriptor is a root descriptor.

A root descriptor is a descriptor without a parent.

isTestback to summary
public default boolean isTest()

Determine if this descriptor describes a test.

The default implementation delegates to Type#isTest().

mayRegisterTestsback to summary
public default boolean mayRegisterTests()

Determine if this descriptor may register dynamic tests during execution.

The default implementation assumes tests are usually known during discovery and thus returns false.

pruneback to summary
public default void prune()

Remove this descriptor from the hierarchy unless it is a root or contains tests.

A concrete TestEngine may override this method in order to implement a different algorithm or to skip pruning altogether.

See Also
isRoot(), containsTests(TestDescriptor), removeFromHierarchy()
removeChildback to summary
public void removeChild(TestDescriptor descriptor)

Remove a child from this descriptor.

Parameters
descriptor:TestDescriptor

the child to remove from this descriptor; never null

removeFromHierarchyback to summary
public void 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.

setParentback to summary
public void setParent(TestDescriptor parent)

Set the parent of this descriptor.

Parameters
parent:TestDescriptor

the new parent of this descriptor; may be null.

org.junit.platform.engine back to summary

public final Enum TestDescriptor.Type

extends Enum<TestDescriptor.Type>
Class Inheritance

Supported types for TestDescriptors.

Field Summary

Modifier and TypeField and Description
public static final TestDescriptor.Type
CONTAINER

Denotes that the TestDescriptor is for a container.

public static final TestDescriptor.Type
CONTAINER_AND_TEST

Denotes that the TestDescriptor is for a test that may potentially also be a container.

public static final TestDescriptor.Type
TEST

Denotes that the TestDescriptor is for a test.

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this type represents a descriptor that can contain other descriptors
isContainer
()

public boolean

Returns:

true if this type represents a descriptor for a test
isTest
()

public static TestDescriptor.Type
public static TestDescriptor.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONTAINERback to summary
public static final TestDescriptor.Type CONTAINER

Denotes that the TestDescriptor is for a container.

CONTAINER_AND_TESTback to summary
public static final TestDescriptor.Type CONTAINER_AND_TEST

Denotes that the TestDescriptor is for a test that may potentially also be a container.

TESTback to summary
public static final TestDescriptor.Type TEST

Denotes that the TestDescriptor is for a test.

Constructor Detail

Typeback to summary
private Type()

Method Detail

isContainerback to summary
public boolean isContainer()
Returns:boolean

true if this type represents a descriptor that can contain other descriptors

isTestback to summary
public boolean isTest()
Returns:boolean

true if this type represents a descriptor for a test

valueOfback to summary
public static TestDescriptor.Type valueOf(String name)
valuesback to summary
public static TestDescriptor.Type[] values()
org.junit.platform.engine back to summary

public Interface TestDescriptor.Visitor

Annotations
@FunctionalInterface

Visitor for the tree-like TestDescriptor structure.
See Also
TestDescriptor#accept(Visitor)

Method Summary

Modifier and TypeMethod and Description
public void
visit(TestDescriptor
the TestDescriptor to visit; never null
descriptor
)

Visit a TestDescriptor.

Method Detail

visitback to summary
public void visit(TestDescriptor descriptor)

Visit a TestDescriptor.

Parameters
descriptor:TestDescriptor

the TestDescriptor to visit; never null