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 java.lang.Object implements DiscoverySelectorADiscoverySelectorthat selects a nestedMethodor a combination of enclosing class names, class name, method name, and parameter types so thatTestEnginescan discover tests or containers based on methods.If a Java
Methodis provided, the selector will return that method and its method name, class name, enclosing class 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 ifgetEnclosingClasses(),getNestedClass(),getMethod(), orgetParameterTypes()is invoked.In this context, a Java
Methodmeans anything that can be referenced as aMethodon the JVM — for example, methods from Java classes or methods from other JVM languages such Groovy, Scala, etc.- Since:
- 1.6
- See Also:
DiscoverySelectors.selectNestedMethod(List, String, String),DiscoverySelectors.selectNestedMethod(List, String, String, String),DiscoverySelectors.selectNestedMethod(List, Class, String),DiscoverySelectors.selectNestedMethod(List, Class, String, String),DiscoverySelectors.selectNestedMethod(List, Class, Method),MethodSource,NestedClassSelector,MethodSelector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNestedMethodSelector.IdentifierParser
-
Field Summary
Fields Modifier and Type Field Description private MethodSelectormethodSelectorprivate NestedClassSelectornestedClassSelector
-
Constructor Summary
Constructors Constructor Description NestedMethodSelector(java.lang.ClassLoader classLoader, java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName, java.lang.Class<?>... parameterTypes)NestedMethodSelector(java.lang.ClassLoader classLoader, java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName, java.lang.String parameterTypeNames)NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.reflect.Method method)NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.String methodName, java.lang.Class<?>... parameterTypes)NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.String methodName, java.lang.String parameterTypeNames)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.ClassLoadergetClassLoader()Get theClassLoaderused to load the nested class.java.util.List<java.lang.Class<?>>getEnclosingClasses()Get the list ofClassenclosing the nestedClasscontaining the selectedMethod.java.util.List<java.lang.String>getEnclosingClassNames()Get the names of the classes enclosing the nested class containing the selected method.java.lang.reflect.MethodgetMethod()Get the selectedMethod.java.lang.StringgetMethodName()Get the name of the selected method.java.lang.StringgetMethodParameterTypes()Deprecated.since 1.10 in favor orgetParameterTypeNames()java.lang.Class<?>getNestedClass()Get the nestedClasscontaining the selectedMethod.java.lang.StringgetNestedClassName()Get the name of the nested class containing the selected method.java.lang.StringgetParameterTypeNames()Get the names of parameter types for the selected method as aString.java.lang.Class<?>[]getParameterTypes()Get the parameter types for the selected method.inthashCode()java.util.Optional<DiscoverySelectorIdentifier>toIdentifier()Return the identifier of this selector.java.lang.StringtoString()
-
-
-
Field Detail
-
nestedClassSelector
private final NestedClassSelector nestedClassSelector
-
methodSelector
private final MethodSelector methodSelector
-
-
Constructor Detail
-
NestedMethodSelector
NestedMethodSelector(java.lang.ClassLoader classLoader, java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName, java.lang.String parameterTypeNames)
-
NestedMethodSelector
NestedMethodSelector(java.lang.ClassLoader classLoader, java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName, java.lang.Class<?>... parameterTypes)- Since:
- 1.10
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.String methodName, java.lang.String parameterTypeNames)
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.String methodName, java.lang.Class<?>... parameterTypes)- Since:
- 1.10
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.reflect.Method method)
-
-
Method Detail
-
getClassLoader
@API(status=MAINTAINED, since="1.13.3") public java.lang.ClassLoader getClassLoader()Get theClassLoaderused to load the nested class.- Since:
- 1.10
-
getEnclosingClassNames
public java.util.List<java.lang.String> getEnclosingClassNames()
Get the names of the classes enclosing the nested class containing the selected method.
-
getEnclosingClasses
public java.util.List<java.lang.Class<?>> getEnclosingClasses()
Get the list ofClassenclosing the nestedClasscontaining the selectedMethod.If the
Classwere not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the list of enclosingClassand throws aPreconditionViolationExceptionif the classes cannot be loaded.
-
getNestedClassName
public java.lang.String getNestedClassName()
Get the name of the nested class containing the selected method.
-
getNestedClass
public java.lang.Class<?> getNestedClass()
Get the nestedClasscontaining the selectedMethod.If the
Classwere not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the nestedClassand throws aPreconditionViolationExceptionif the class cannot be loaded.
-
getMethodName
public java.lang.String getMethodName()
Get the name of the selected method.
-
getMethod
public java.lang.reflect.Method getMethod()
Get the selectedMethod.If the
Methodwas not provided, but only the name, this method attempts to lazily load theMethodbased on its name and throws aPreconditionViolationExceptionif the method cannot be loaded.
-
getMethodParameterTypes
@Deprecated @API(status=DEPRECATED, since="1.10") public java.lang.String getMethodParameterTypes()Deprecated.since 1.10 in favor orgetParameterTypeNames()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(),getParameterTypes()
-
getParameterTypeNames
@API(status=STABLE, since="1.10") public java.lang.String getParameterTypeNames()Get the names of parameter types for the selected method as aString.See
MethodSelector.getParameterTypeNames()for details.- Returns:
- the names of parameter types supplied to this
NestedMethodSelectorvia a constructor or deduced from aMethodor parameter types supplied via a constructor; nevernullbut potentially an empty string - Since:
- 1.10
- See Also:
MethodSelector.getParameterTypeNames()
-
getParameterTypes
@API(status=MAINTAINED, since="1.13.3") public java.lang.Class<?>[] getParameterTypes()Get the parameter types for the selected method.See
MethodSelector.getParameterTypes()for details.- Returns:
- the method's parameter types; never
nullbut potentially an empty array if the selected method does not declare parameters - Since:
- 1.10
- See Also:
getParameterTypeNames(),MethodSelector.getParameterTypes()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toIdentifier
public java.util.Optional<DiscoverySelectorIdentifier> toIdentifier()
Description copied from interface:DiscoverySelectorReturn 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:
toIdentifierin interfaceDiscoverySelector- Returns:
- an
Optionalcontaining the identifier of this selector; nevernullbut potentially empty if the selector does not support identifiers
-
-