Top Description Fields Constructors Methods
org.junit.platform.launcher

public final Class TestIdentifier

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@API
status:STABLE
since:1.0
Static Imports
java.util.Collections.emptySet, .Collections.unmodifiableSet, org.apiguardian.api.API.Status.INTERNAL, .API.Status.STABLE, org.junit.platform.commons.util.CollectionUtils.getOnlyElement

Immutable data transfer object that represents a test or container which is usually part of a TestPlan.
Since
1.0
See Also
TestPlan

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final @Nullable UniqueId
private static final long
private final @Nullable TestSource
private final Set<TestTag>
private final TestDescriptor.Type
private final UniqueId

Constructor Summary

AccessConstructor and Description
private
TestIdentifier(UniqueId uniqueId, String displayName, @Nullable TestSource source, Set<TestTag> tags, TestDescriptor.Type type, @Nullable UniqueId parentId, String legacyReportingName)

Method Summary

Modifier and TypeMethod and Description
private Set<TestTag>
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

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

public static TestIdentifier
from(TestDescriptor testDescriptor)

Factory for creating a new TestIdentifier from a TestDescriptor.

public String

Returns:

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

Get the display name of the represented test or container.

public String

Returns:

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

Get the name of this identifier 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<String>

Returns:

a container for the unique ID for this identifier's parent; never null though potentially empty
getParentId
()

Get the unique ID of this identifier's parent as a String, if available.

public Optional<UniqueId>

Returns:

a container for the unique ID for this identifier's parent; never null though potentially empty
getParentIdObject
()

Get the unique ID of this identifier's parent as a UniqueId, if available.

public Optional<TestSource>
getSource()

Get the source of the represented test or container, if available.

public Set<TestTag>
getTags()

Get the set of tags associated with the represented test or container.

public TestDescriptor.Type

Returns:

the underlying descriptor type; never null
getType
()

Get the underlying descriptor type.

public String

Returns:

the unique ID for this identifier; never null
getUniqueId
()

Get the unique ID of the represented test or container as a String.

public UniqueId

Returns:

the unique ID for this identifier; never null
getUniqueIdObject
()

Get the unique ID of the represented test or container as a UniqueId.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if the underlying descriptor type represents a container, false otherwise
isContainer
()

Determine if this identifier represents a container.

public boolean

Returns:

true if the underlying descriptor type represents a test, false otherwise
isTest
()

Determine if this identifier represents a test.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

displayNameback to summary
private final String displayName
legacyReportingNameback to summary
private final String legacyReportingName
parentIdback to summary
private final @Nullable UniqueId parentId
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial
sourceback to summary
private final @Nullable TestSource source
tagsback to summary
private final Set<TestTag> tags
Annotations
@SuppressWarnings:serial
typeback to summary
private final TestDescriptor.Type type
uniqueIdback to summary
private final UniqueId uniqueId

Constructor Detail

TestIdentifierback to summary
private TestIdentifier(UniqueId uniqueId, String displayName, @Nullable TestSource source, Set<TestTag> tags, TestDescriptor.Type type, @Nullable UniqueId parentId, String legacyReportingName)

Method Detail

copyOfback to summary
private Set<TestTag> copyOf(Set<TestTag> tags)
equalsback to summary
public boolean equals(Object obj)

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
fromback to summary
public static TestIdentifier from(TestDescriptor testDescriptor)

Factory for creating a new TestIdentifier from a TestDescriptor.

Annotations
@API
status:INTERNAL
since:1.0
getDisplayNameback to summary
public String getDisplayName()

Get the display name of the represented test or container.

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 identifier; never null or blank

See Also
getSource(), org.junit.platform.engine.TestDescriptor#getDisplayName()
getLegacyReportingNameback to summary
public String getLegacyReportingName()

Get the name of this identifier 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

Annotations
@SuppressWarnings:JavadocReference
See Also
org.junit.platform.engine.TestDescriptor#getLegacyReportingName(), org.junit.platform.reporting.legacy.LegacyReportingUtils
getParentIdback to summary
public Optional<String> getParentId()

Get the unique ID of this identifier's parent as a String, if available.

An identifier without a parent is called a root.

Returns:Optional<String>

a container for the unique ID for this identifier's parent; never null though potentially empty

getParentIdObjectback to summary
public Optional<UniqueId> getParentIdObject()

Get the unique ID of this identifier's parent as a UniqueId, if available.

An identifier without a parent is called a root.

Returns:Optional<UniqueId>

a container for the unique ID for this identifier's parent; never null though potentially empty

Annotations
@API
status:STABLE
since:1.8
Since
1.8
getSourceback to summary
public Optional<TestSource> getSource()

Get the source of the represented test or container, if available.

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

Get the set of tags associated with the represented test or container.

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

Get the underlying descriptor type.

Returns:TestDescriptor.Type

the underlying descriptor type; never null

getUniqueIdback to summary
public String getUniqueId()

Get the unique ID of the represented test or container as a String.

Uniqueness must be guaranteed across an entire test plan, regardless of how many engines are used behind the scenes.

Returns:String

the unique ID for this identifier; never null

getUniqueIdObjectback to summary
public UniqueId getUniqueIdObject()

Get the unique ID of the represented test or container as a UniqueId.

Uniqueness must be guaranteed across an entire test plan, regardless of how many engines are used behind the scenes.

Returns:UniqueId

the unique ID for this identifier; never null

Annotations
@API
status:STABLE
since:1.8
Since
1.8
hashCodeback to summary
public 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
isContainerback to summary
public boolean isContainer()

Determine if this identifier represents a container.

Returns:boolean

true if the underlying descriptor type represents a container, false otherwise

See Also
Type#isContainer()
isTestback to summary
public boolean isTest()

Determine if this identifier represents a test.

Returns:boolean

true if the underlying descriptor type represents a test, false otherwise

See Also
Type#isTest()
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