Module org.junit.platform.engine
Class MethodSource
java.lang.Object
org.junit.platform.engine.support.descriptor.MethodSource
- All Implemented Interfaces:
Serializable
,TestSource
Method based
TestSource
.
This class stores the method name along with the names of its parameter
types because Method
does not implement Serializable
.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static MethodSource
static MethodSource
Create a newMethodSource
using the suppliedmethod
.static MethodSource
Create a newMethodSource
using the supplied class name and method name.static MethodSource
Create a newMethodSource
using the supplied class name, method name, and method parameter types.static MethodSource
Create a newMethodSource
using the supplied class name, method name, and method parameter types.Get the class name of this source.final Class<?>
Get the Java class of this source.final Method
Get the Java method of this source.final String
Get the method name of this source.final String
Get the method parameter types of this source.int
hashCode()
toString()
-
Method Details
-
from
Create a newMethodSource
using the supplied class name and method name.- Parameters:
className
- the class name; must not benull
or blankmethodName
- the method name; must not benull
or blank
-
from
Create a newMethodSource
using the supplied class name, method name, and method parameter types.- Parameters:
className
- the class name; must not benull
or blankmethodName
- the method name; must not benull
or blankmethodParameterTypes
- a comma-separated list of fully qualified class names representing the method parameter types
-
from
@API(status=STABLE, since="1.5") public static MethodSource from(String className, String methodName, Class<?>... methodParameterTypes) Create a newMethodSource
using the supplied class name, method name, and method parameter types.- Parameters:
className
- the class name; must not benull
or blankmethodName
- the method name; must not benull
or blankmethodParameterTypes
- a varargs array of classes representing the method parameter types- Since:
- 1.5
-
from
Create a newMethodSource
using the suppliedmethod
.- Parameters:
testMethod
- the Java method; must not benull
- See Also:
-
from
@API(status=STABLE, since="1.3") public static MethodSource from(Class<?> testClass, Method testMethod) Create a newMethodSource
using the suppliedclass
andmethod
.This method should be used in favor of
from(Method)
if the test method is inherited from a superclass or present as an interfacedefault
method.- Parameters:
testClass
- the Java class; must not benull
testMethod
- the Java method; must not benull
- Since:
- 1.3
-
getClassName
Get the class name of this source. -
getMethodName
Get the method name of this source. -
getMethodParameterTypes
Get the method parameter types of this source. -
getJavaClass
Get the Java class of this source.If the
Class
was not provided, but only the name, this method attempts to lazily load theClass
based on its name and throws aPreconditionViolationException
if the class cannot be loaded.- Since:
- 1.7
- See Also:
-
getJavaMethod
Get the Java method of this source.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.- Since:
- 1.7
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-