Class TestTag

java.lang.Object
org.junit.platform.engine.TestTag
All Implemented Interfaces:
Serializable

@API(status=STABLE, since="1.0") public final class TestTag extends Object implements Serializable
Immutable value object for a tag that is assigned to a test or container.
Since:
1.0
See Also:
  • Field Details

    • RESERVED_CHARACTERS

      public static final Set<String> RESERVED_CHARACTERS
      Reserved characters that are not permissible as part of a tag name.
      • ,: comma
      • (: left parenthesis
      • ): right parenthesis
      • &: ampersand
      • |: vertical bar
      • !: exclamation point
  • Method Details

    • isValid

      public static boolean isValid(String name)
      Determine if the supplied tag name is valid with regard to the supported syntax for tags.

      Syntax Rules for Tags

      • A tag must not be null.
      • A tag must not be blank.
      • A trimmed tag must not contain whitespace.
      • A trimmed tag must not contain ISO control characters.
      • A trimmed tag must not contain reserved characters.

      If this method returns true for a given name, it is then a valid candidate for the create() factory method.

      Parameters:
      name - the name of the tag to validate; may be null or blank
      Returns:
      true if the supplied tag name conforms to the supported syntax for tags
      See Also:
    • create

      public static TestTag create(String name) throws org.junit.platform.commons.PreconditionViolationException
      Create a TestTag from the supplied name.

      Consider checking whether the syntax of the supplied name is valid before attempting to create a TestTag using this factory method.

      Note: the supplied name will be trimmed.

      Parameters:
      name - the name of the tag; must be syntactically valid
      Throws:
      org.junit.platform.commons.PreconditionViolationException - if the supplied tag name is not syntactically valid
      See Also:
    • getName

      public String getName()
      Get the name of this tag.
      Returns:
      the name of this tag; never null or blank
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object