Class MethodSelector

  • All Implemented Interfaces:
    DiscoverySelector


    @API(status=STABLE,
         since="1.0")
    public class MethodSelector
    extends java.lang.Object
    implements DiscoverySelector
    A DiscoverySelector that selects a Method or a combination of 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, and parameter types accordingly. If a Class and method name, a class name and method name, or simply a fully qualified method name is provided, this selector will only attempt to lazily load the Class and Method if getJavaClass() or getJavaMethod() 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.0
    See Also:
    MethodSource
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getClassName​()
      Get the selected class name.
      java.lang.Class<?> getJavaClass​()
      Get the Class in which the selected method is declared, or a subclass thereof.
      java.lang.reflect.Method getJavaMethod​()
      Get the selected Method.
      java.lang.String getMethodName​()
      Get the selected method name.
      java.lang.String getMethodParameterTypes​()
      Get the parameter types for the selected method as a String, typically a comma-separated list of primitive types, fully qualified class names, or array types.
      java.lang.String toString​()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getClassName

        public java.lang.String getClassName​()
        Get the selected class name.
      • getMethodName

        public java.lang.String getMethodName​()
        Get the selected method name.
      • getMethodParameterTypes

        public java.lang.String getMethodParameterTypes​()
        Get the parameter types for the selected method as a String, typically a comma-separated list of primitive types, fully qualified class names, or array types.

        Note: the parameter types are provided as a single string instead of a collection in order to allow this selector to be used in a generic fashion by various test engines. It is therefore the responsibility of the caller of this method to determine how to parse the returned string.

        Returns:
        the parameter types supplied to this MethodSelector via a constructor or deduced from a Method supplied via a constructor; never null
      • getJavaClass

        public java.lang.Class<?> getJavaClass​()
        Get the Class in which the selected method is declared, or a subclass thereof.

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

        See Also:
        getJavaMethod()
      • getJavaMethod

        public java.lang.reflect.Method getJavaMethod​()
        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.

        See Also:
        getJavaClass()
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object