Class TestIdentifier
- java.lang.Object
-
- org.junit.platform.launcher.TestIdentifier
-
- All Implemented Interfaces:
java.io.Serializable
@API(status=STABLE, since="1.0") public final class TestIdentifier extends java.lang.Object implements java.io.Serializable
Immutable data transfer object that represents a test or container which is usually part of aTestPlan
.- Since:
- 1.0
- See Also:
TestPlan
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TestIdentifier.SerializedForm
Represents the serialized output ofTestIdentifier
.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
displayName
private java.lang.String
legacyReportingName
private UniqueId
parentId
private static java.io.ObjectStreamField[]
serialPersistentFields
private static long
serialVersionUID
private TestSource
source
private java.util.Set<TestTag>
tags
private TestDescriptor.Type
type
private UniqueId
uniqueId
-
Constructor Summary
Constructors Modifier Constructor Description private
TestIdentifier(UniqueId uniqueId, java.lang.String displayName, TestSource source, java.util.Set<TestTag> tags, TestDescriptor.Type type, UniqueId parentId, java.lang.String legacyReportingName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Set<TestTag>
copyOf(java.util.Set<TestTag> tags)
boolean
equals(java.lang.Object obj)
static TestIdentifier
from(TestDescriptor testDescriptor)
Factory for creating a newTestIdentifier
from aTestDescriptor
.java.lang.String
getDisplayName()
Get the display name of the represented test or container.java.lang.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.java.util.Optional<java.lang.String>
getParentId()
Get the unique ID of this identifier's parent as aString
, if available.java.util.Optional<UniqueId>
getParentIdObject()
Get the unique ID of this identifier's parent as aUniqueId
, if available.java.util.Optional<TestSource>
getSource()
Get the source of the represented test or container, if available.java.util.Set<TestTag>
getTags()
Get the set of tags associated with the represented test or container.TestDescriptor.Type
getType()
Get the underlying descriptor type.java.lang.String
getUniqueId()
Get the unique ID of the represented test or container as aString
.UniqueId
getUniqueIdObject()
Get the unique ID of the represented test or container as aUniqueId
.int
hashCode()
boolean
isContainer()
Determine if this identifier represents a container.boolean
isTest()
Determine if this identifier represents a test.private void
readObject(java.io.ObjectInputStream s)
java.lang.String
toString()
private void
writeObject(java.io.ObjectOutputStream s)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
serialPersistentFields
private static final java.io.ObjectStreamField[] serialPersistentFields
-
uniqueId
private UniqueId uniqueId
-
parentId
private UniqueId parentId
-
displayName
private java.lang.String displayName
-
legacyReportingName
private java.lang.String legacyReportingName
-
source
private TestSource source
-
tags
private java.util.Set<TestTag> tags
-
type
private TestDescriptor.Type type
-
-
Constructor Detail
-
TestIdentifier
private TestIdentifier(UniqueId uniqueId, java.lang.String displayName, TestSource source, java.util.Set<TestTag> tags, TestDescriptor.Type type, UniqueId parentId, java.lang.String legacyReportingName)
-
-
Method Detail
-
from
@API(status=INTERNAL, since="1.0") public static TestIdentifier from(TestDescriptor testDescriptor)
Factory for creating a newTestIdentifier
from aTestDescriptor
.
-
getUniqueId
public java.lang.String getUniqueId()
Get the unique ID of the represented test or container as aString
.Uniqueness must be guaranteed across an entire test plan, regardless of how many engines are used behind the scenes.
- Returns:
- the unique ID for this identifier; never
null
-
getUniqueIdObject
@API(status=STABLE, since="5.8") public UniqueId getUniqueIdObject()
Get the unique ID of the represented test or container as aUniqueId
.Uniqueness must be guaranteed across an entire test plan, regardless of how many engines are used behind the scenes.
- Returns:
- the unique ID for this identifier; never
null
- Since:
- 5.8
-
getParentId
public java.util.Optional<java.lang.String> getParentId()
Get the unique ID of this identifier's parent as aString
, if available.An identifier without a parent is called a root.
- Returns:
- a container for the unique ID for this identifier's parent;
never
null
though potentially empty
-
getParentIdObject
@API(status=STABLE, since="5.8") public java.util.Optional<UniqueId> getParentIdObject()
Get the unique ID of this identifier's parent as aUniqueId
, if available.An identifier without a parent is called a root.
- Returns:
- a container for the unique ID for this identifier's parent;
never
null
though potentially empty - Since:
- 5.8
-
getDisplayName
public java.lang.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:
- the display name for this identifier; never
null
or blank - See Also:
getSource()
,TestDescriptor.getDisplayName()
-
getLegacyReportingName
public java.lang.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:
- the legacy reporting name; never
null
or blank - See Also:
TestDescriptor.getLegacyReportingName()
,LegacyReportingUtils
-
getType
public TestDescriptor.Type getType()
Get the underlying descriptor type.- Returns:
- the underlying descriptor type; never
null
-
isTest
public boolean isTest()
Determine if this identifier represents a test.- Returns:
true
if the underlying descriptor type represents a test,false
otherwise- See Also:
TestDescriptor.Type.isTest()
-
isContainer
public boolean isContainer()
Determine if this identifier represents a container.- Returns:
true
if the underlying descriptor type represents a container,false
otherwise- See Also:
TestDescriptor.Type.isContainer()
-
getSource
public java.util.Optional<TestSource> getSource()
Get the source of the represented test or container, if available.- See Also:
TestSource
-
getTags
public java.util.Set<TestTag> getTags()
Get the set of tags associated with the represented test or container.- See Also:
TestTag
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream s) throws java.lang.ClassNotFoundException, java.io.IOException
- Throws:
java.lang.ClassNotFoundException
java.io.IOException
-
-