Package org.junit.runners.model
Class FrameworkMethod
- java.lang.Object
-
- org.junit.runners.model.FrameworkMember<FrameworkMethod>
-
- org.junit.runners.model.FrameworkMethod
-
- All Implemented Interfaces:
Annotatable
public class FrameworkMethod extends FrameworkMember<FrameworkMethod>
Represents a method on a test class to be invoked at the appropriate point in test execution. These methods are usually marked with an annotation (such as@Test,@Before,@After,@BeforeClass,@AfterClass, etc.)- Since:
- 4.5
-
-
Constructor Summary
Constructors Constructor Description FrameworkMethod(Method method)Returns a newFrameworkMethodformethod
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object obj)<T extends Annotation>
TgetAnnotation(Class<T> annotationType)Returns the annotation of typeannotationTypeon this method, if one exists.Annotation[]getAnnotations()Returns the annotations on this methodClass<?>getDeclaringClass()Returns the class where the method is actually declaredMethodgetMethod()Returns the underlying Java methodprotected intgetModifiers()StringgetName()Returns the method's nameClass<?>getReturnType()Returns the return type of the methodClass<?>getType()Returns the return type of the methodinthashCode()ObjectinvokeExplosively(Object target, Object... params)Returns the result of invoking this method ontargetwith parametersparams.booleanisShadowedBy(FrameworkMethod other)booleanproducesType(Type type)Deprecated.This is used only by the Theories runner, and does not use all the generic type info that it ought to.StringtoString()voidvalidateNoTypeParametersOnArgs(List<Throwable> errors)voidvalidatePublicVoid(boolean isStatic, List<Throwable> errors)Adds toerrorsif this method: is not public, or returns something other than void, or is static (givenisStatic is false), or is not static (givenisStatic is true).voidvalidatePublicVoidNoArg(boolean isStatic, List<Throwable> errors)Adds toerrorsif this method: is not public, or takes parameters, or returns something other than void, or is static (givenisStatic is false), or is not static (givenisStatic is true).-
Methods inherited from class org.junit.runners.model.FrameworkMember
isPublic, isStatic
-
-
-
-
Constructor Detail
-
FrameworkMethod
public FrameworkMethod(Method method)
Returns a newFrameworkMethodformethod
-
-
Method Detail
-
invokeExplosively
public Object invokeExplosively(Object target, Object... params) throws Throwable
Returns the result of invoking this method ontargetwith parametersparams.InvocationTargetExceptions thrown are unwrapped, and their causes rethrown.- Throws:
Throwable
-
getName
public String getName()
Returns the method's name- Specified by:
getNamein classFrameworkMember<FrameworkMethod>
-
validatePublicVoidNoArg
public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors)
Adds toerrorsif this method:- is not public, or
- takes parameters, or
- returns something other than void, or
- is static (given
isStatic is false), or - is not static (given
isStatic is true).
-
validatePublicVoid
public void validatePublicVoid(boolean isStatic, List<Throwable> errors)
Adds toerrorsif this method:- is not public, or
- returns something other than void, or
- is static (given
isStatic is false), or - is not static (given
isStatic is true).
-
getModifiers
protected int getModifiers()
- Specified by:
getModifiersin classFrameworkMember<FrameworkMethod>
-
getReturnType
public Class<?> getReturnType()
Returns the return type of the method
-
getType
public Class<?> getType()
Returns the return type of the method- Specified by:
getTypein classFrameworkMember<FrameworkMethod>
-
getDeclaringClass
public Class<?> getDeclaringClass()
Returns the class where the method is actually declared- Specified by:
getDeclaringClassin classFrameworkMember<FrameworkMethod>
-
validateNoTypeParametersOnArgs
public void validateNoTypeParametersOnArgs(List<Throwable> errors)
-
isShadowedBy
public boolean isShadowedBy(FrameworkMethod other)
-
producesType
@Deprecated public boolean producesType(Type type)
Deprecated.This is used only by the Theories runner, and does not use all the generic type info that it ought to. It will be replaced with a forthcoming ParameterSignature#canAcceptResultOf(FrameworkMethod) once Theories moves to junit-contrib.Returns true if this is a no-arg method that returns a value assignable totype
-
getAnnotations
public Annotation[] getAnnotations()
Returns the annotations on this method
-
getAnnotation
public <T extends Annotation> T getAnnotation(Class<T> annotationType)
Returns the annotation of typeannotationTypeon this method, if one exists.
-
-