@API(value=Experimental) public class MethodSelector extends Object implements DiscoverySelector
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 and class names accordingly. If a Class
and method name, a class name and method name, or simply a fully qualified
method name is provided, the selector will only attempt to lazily load the
Class
and Method
if getJavaClass()
or
getJavaMethod()
is invoked.
In this context, Java Method
means anything that can be referenced
as a Method
on the JVM — for example, methods from other JVM
languages such Groovy, Scala, etc.
MethodSource
Constructor and Description |
---|
MethodSelector(Class<?> javaClass,
String methodName,
String methodParameterTypes) |
Modifier and Type | Method and Description |
---|---|
String |
getClassName()
Get the selected class name.
|
Class<?> |
getJavaClass()
|
Method |
getJavaMethod()
Get the selected
Method . |
String |
getMethodName()
Get the selected method name.
|
String |
getMethodParameterTypes()
Get the parameter types for the selected method as a
String ,
typically a comma-separated list of atomic types, fully qualified class
names, or array types. |
String |
toString() |
public String getClassName()
public String getMethodName()
public String getMethodParameterTypes()
String
,
typically a comma-separated list of atomic 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.
public Class<?> getJavaClass()
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.
getJavaMethod()
public Method getJavaMethod()
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.
getJavaClass()