Class NestedMethodSelector

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

@API(status=STABLE, since="1.6") public class NestedMethodSelector extends Object implements DiscoverySelector
A DiscoverySelector that selects a nested Method or a combination of enclosing classes names, class name, method name, and parameter types so that TestEngines can discover tests or containers based on methods.

If a Java Method is provided, the selector will return that method and its method name, class name, enclosing classes names, and parameter types accordingly. If class names or method names are provided, this selector will only attempt to lazily load a class or method if getEnclosingClasses(), getNestedClass(), getMethod(), or getParameterTypes() is invoked.

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

Since:
1.6
See Also:
  • Field Details

  • Constructor Details

    • NestedMethodSelector

      NestedMethodSelector(ClassLoader classLoader, List<String> enclosingClassNames, String nestedClassName, String methodName, String parameterTypeNames)
    • NestedMethodSelector

      NestedMethodSelector(ClassLoader classLoader, List<String> enclosingClassNames, String nestedClassName, String methodName, Class<?>... parameterTypes)
      Since:
      1.10
    • NestedMethodSelector

      NestedMethodSelector(List<Class<?>> enclosingClasses, Class<?> nestedClass, String methodName, String parameterTypeNames)
    • NestedMethodSelector

      NestedMethodSelector(List<Class<?>> enclosingClasses, Class<?> nestedClass, String methodName, Class<?>... parameterTypes)
      Since:
      1.10
    • NestedMethodSelector

      NestedMethodSelector(List<Class<?>> enclosingClasses, Class<?> nestedClass, Method method)
  • Method Details

    • getClassLoader

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

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

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

      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 nested class containing the selected method.
    • getNestedClass

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

      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.

    • getMethodName

      public String getMethodName()
      Get the name of the selected method.
    • getMethod

      public Method getMethod()
      Get the selected Method.

      If the Method was not provided, but only the name, this method attempts to lazily load the Method based on its name and throws a PreconditionViolationException if the method cannot be loaded.

    • getMethodParameterTypes

      @Deprecated @API(status=DEPRECATED, since="1.10") public String getMethodParameterTypes()
      Deprecated.
      since 1.10 in favor or getParameterTypeNames()
      Get the names of parameter types for the selected method.

      See getParameterTypeNames() for details.

      Returns:
      the names of parameter types
      Since:
      1.6
      See Also:
    • getParameterTypeNames

      @API(status=STABLE, since="1.10") public String getParameterTypeNames()
      Get the names of parameter types for the selected method as a String.

      See MethodSelector.getParameterTypeNames() for details.

      Returns:
      the names of parameter types supplied to this NestedMethodSelector via a constructor or deduced from a Method or parameter types supplied via a constructor; never null but potentially an empty string
      Since:
      1.10
      See Also:
    • getParameterTypes

      @API(status=EXPERIMENTAL, since="1.10") public Class<?>[] getParameterTypes()
      Get the parameter types for the selected method.

      See MethodSelector.getParameterTypes() for details.

      Returns:
      the method's parameter types; never null but potentially an empty array if the selected method does not declare parameters
      Since:
      1.10
      See Also:
    • 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