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 DiscoverySelector
ADiscoverySelector
that selects a nestedMethod
or a combination of enclosing classes names, class name, method name, and parameter types so thatTestEngines
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 or methods names are provided, this selector will only attempt to lazily load theClass
andMethod
ifgetEnclosingClasses()
,getNestedClass()
orgetMethod()
is invoked.In this context, a Java
Method
means anything that can be referenced as aMethod
on 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
-
-
Field Summary
Fields Modifier and Type Field Description private MethodSelector
methodSelector
private NestedClassSelector
nestedClassSelector
-
Constructor Summary
Constructors Constructor Description 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)
NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.String methodName, java.lang.String methodParameterTypes)
NestedMethodSelector(java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName)
NestedMethodSelector(java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName, java.lang.String methodParameterTypes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.util.List<java.lang.Class<?>>
getEnclosingClasses()
Get the list ofClass
enclosing the nestedClass
containing 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.Method
getMethod()
Get the selectedMethod
.java.lang.String
getMethodName()
Get the name of the selected method.java.lang.String
getMethodParameterTypes()
Get the parameter types for the selected method as aString
, typically a comma-separated list of primitive types, fully qualified class names, or array types.java.lang.Class<?>
getNestedClass()
Get the nestedClass
containing the selectedMethod
.java.lang.String
getNestedClassName()
Get the name of the nested class containing the selected method.int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
nestedClassSelector
private final NestedClassSelector nestedClassSelector
-
methodSelector
private final MethodSelector methodSelector
-
-
Constructor Detail
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName)
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName, java.lang.String methodName, java.lang.String methodParameterTypes)
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.String methodName)
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.String methodName, java.lang.String methodParameterTypes)
-
NestedMethodSelector
NestedMethodSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass, java.lang.reflect.Method method)
-
-
Method Detail
-
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 ofClass
enclosing the nestedClass
containing the selectedMethod
.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 enclosingClass
and throws aPreconditionViolationException
if 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 nestedClass
containing the selectedMethod
.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 nestedClass
and throws aPreconditionViolationException
if 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
Method
was not provided, but only the name, this method attempts to lazily load theMethod
based on its name and throws aPreconditionViolationException
if the method cannot be loaded.
-
getMethodParameterTypes
public java.lang.String getMethodParameterTypes()
Get the parameter types for the selected method as aString
, 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
NestedMethodSelector
via a constructor or deduced from aMethod
supplied via a constructor; nevernull
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-