Class NestedClassSelector

java.lang.Object
org.junit.platform.engine.discovery.NestedClassSelector
All Implemented Interfaces:
DiscoverySelector

@API(status=STABLE, since="1.6") public class NestedClassSelector extends Object implements DiscoverySelector
A DiscoverySelector that selects a nested Class or class name enclosed in other classes so that TestEngines can discover tests or containers based on classes.

If Java Class references are provided for the nested class or the enclosing classes, the selector will return those classes and their class names accordingly. If class names are provided, the selector will only attempt to lazily load classes if getEnclosingClasses() or getNestedClass() is invoked.

In this context, Java Class means anything that can be referenced as a Class on the JVM — for example, classes from other JVM languages such Groovy, Scala, etc.

Since:
1.6
See Also:
  • Method Details

    • getClassLoader

      @API(status=EXPERIMENTAL, since="1.10") public ClassLoader getClassLoader()
      Get the ClassLoader used to load the selected nested class.
      Returns:
      the ClassLoader; potentially null
      Since:
      1.10
    • getEnclosingClassNames

      public List<String> getEnclosingClassNames()
      Get the names of the classes enclosing the selected nested class.
    • getEnclosingClasses

      public List<Class<?>> getEnclosingClasses()
      Get the list of Class enclosing the selected nested Class.

      If the Class were not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the list of enclosing Class and throws a PreconditionViolationException if the classes cannot be loaded.

    • getNestedClassName

      public String getNestedClassName()
      Get the name of the selected nested class.
    • getNestedClass

      public Class<?> getNestedClass()
      Get the selected nested Class.

      If the Class were not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the nested Class and throws a PreconditionViolationException if the class cannot be loaded.

    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • toIdentifier

      public Optional<DiscoverySelectorIdentifier> toIdentifier()
      Description copied from interface: DiscoverySelector
      Return the identifier of this selector.

      The returned identifier must be parsable by a corresponding DiscoverySelectorIdentifierParser.

      The default implementation returns Optional.empty(). Can be overridden by concrete implementations.

      Specified by:
      toIdentifier in interface DiscoverySelector
      Returns:
      an Optional containing the identifier of this selector; never null but potentially empty if the selector does not support identifiers