Class MethodSelector
- java.lang.Object
-
- org.junit.platform.engine.discovery.MethodSelector
-
- All Implemented Interfaces:
DiscoverySelector
@API(status=STABLE, since="1.0") public class MethodSelector extends Object implements DiscoverySelector
ADiscoverySelectorthat selects aMethodor a combination of 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, and parameter types accordingly. If aClassand 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 theClassandMethodifgetJavaClass()orgetJavaMethod()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.0
- See Also:
DiscoverySelectors.selectMethod(String),DiscoverySelectors.selectMethod(String, String),DiscoverySelectors.selectMethod(String, String, String),DiscoverySelectors.selectMethod(Class, String),DiscoverySelectors.selectMethod(Class, String, String),DiscoverySelectors.selectMethod(Class, Method),MethodSource
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetClassName()Get the selected class name.Class<?>getJavaClass()MethodgetJavaMethod()Get the selectedMethod.StringgetMethodName()Get the selected method name.StringgetMethodParameterTypes()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.StringtoString()
-
-
-
Method Detail
-
getClassName
public String getClassName()
Get the selected class name.
-
getMethodName
public String getMethodName()
Get the selected method name.
-
getMethodParameterTypes
public 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
MethodSelectorvia a constructor or deduced from aMethodsupplied via a constructor; nevernull
-
getJavaClass
public Class<?> getJavaClass()
Get theClassin which the selected method is declared, or a subclass thereof.If the
Classwas not provided, but only the name, this method attempts to lazily load theClassbased on its name and throws aPreconditionViolationExceptionif the class cannot be loaded.- See Also:
getJavaMethod()
-
getJavaMethod
public Method getJavaMethod()
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.- See Also:
getJavaClass()
-
-