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 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 Details

  • Constructor Details

    • AbstractTestDescriptor

      protected AbstractTestDescriptor(UniqueId uniqueId, String displayName)
      Create a new AbstractTestDescriptor with the supplied UniqueId and display name.
      Parameters:
      uniqueId - the unique ID of this TestDescriptor; never null
      displayName - the display name for this TestDescriptor; never null or blank
      See Also:
      AbstractTestDescriptor(UniqueId, String, TestSource)
    • AbstractTestDescriptor

      protected AbstractTestDescriptor(UniqueId uniqueId, String displayName, TestSource source)
      Create a new AbstractTestDescriptor with the supplied UniqueId, display name, and source.
      Parameters:
      uniqueId - the unique ID of this TestDescriptor; never null
      displayName - the display name for this TestDescriptor; never null or blank
      source - the source of the test or container described by this TestDescriptor; can be null
      See Also:
      AbstractTestDescriptor(UniqueId, String)
  • Method Details

    • getUniqueId

      public final UniqueId getUniqueId()
      Description copied from interface: TestDescriptor
      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.

      Specified by:
      getUniqueId in interface TestDescriptor
      Returns:
      the UniqueId for this descriptor; never null
    • getDisplayName

      public final String getDisplayName()
      Description copied from interface: TestDescriptor
      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.

      Specified by:
      getDisplayName in interface TestDescriptor
      Returns:
      the display name for this descriptor; never null or blank
      See Also:
      TestDescriptor.getSource()
    • getTags

      public Set<TestTag> getTags()
      Description copied from interface: TestDescriptor
      Get the set of tags associated with this descriptor.
      Specified by:
      getTags in interface TestDescriptor
      Returns:
      the set of tags associated with this descriptor; never null but potentially empty
      See Also:
      TestTag
    • getSource

      public Optional<TestSource> getSource()
      Description copied from interface: TestDescriptor
      Get the source of the test or container described by this descriptor, if available.
      Specified by:
      getSource in interface TestDescriptor
      See Also:
      TestSource
    • getParent

      public final Optional<TestDescriptor> getParent()
      Description copied from interface: TestDescriptor
      Get the parent of this descriptor, if available.
      Specified by:
      getParent in interface TestDescriptor
    • setParent

      public final void setParent(TestDescriptor parent)
      Description copied from interface: TestDescriptor
      Set the parent of this descriptor.
      Specified by:
      setParent in interface TestDescriptor
      Parameters:
      parent - the new parent of this descriptor; may be null.
    • getChildren

      public final Set<? extends TestDescriptor> getChildren()
      Description copied from interface: TestDescriptor
      Get the immutable set of children of this descriptor.
      Specified by:
      getChildren in interface TestDescriptor
      Returns:
      the set of children of this descriptor; neither null nor mutable, but potentially empty
      See Also:
      TestDescriptor.getDescendants()
    • addChild

      public void addChild(TestDescriptor child)
      Description copied from interface: TestDescriptor
      Add a child to this descriptor.
      Specified by:
      addChild in interface TestDescriptor
      Parameters:
      child - the child to add to this descriptor; never null
    • removeChild

      public void removeChild(TestDescriptor child)
      Description copied from interface: TestDescriptor
      Remove a child from this descriptor.
      Specified by:
      removeChild in interface TestDescriptor
      Parameters:
      child - the child to remove from this descriptor; never null
    • removeFromHierarchy

      public void removeFromHierarchy()
      Description copied from interface: TestDescriptor
      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.

      Specified by:
      removeFromHierarchy in interface TestDescriptor
    • findByUniqueId

      public Optional<? extends TestDescriptor> findByUniqueId(UniqueId uniqueId)
      Description copied from interface: TestDescriptor
      Find the descriptor with the supplied unique ID.

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

      Specified by:
      findByUniqueId in interface TestDescriptor
      Parameters:
      uniqueId - the UniqueId to search for; never null
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object