Package org.junit.runners.model
Class FrameworkMethod
- java.lang.Object
-
- org.junit.runners.model.FrameworkMember<FrameworkMethod>
-
- org.junit.runners.model.FrameworkMethod
-
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(java.lang.reflect.Method method)Returns a newFrameworkMethodformethod
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)<T extends java.lang.annotation.Annotation>
TgetAnnotation(java.lang.Class<T> annotationType)Returns the annotation of typeannotationTypeon this method, if one exists.java.lang.annotation.Annotation[]getAnnotations()Returns the annotations on this methodjava.lang.reflect.MethodgetMethod()Returns the underlying Java methodjava.lang.StringgetName()Returns the method's namejava.lang.Class<?>getReturnType()Returns the return type of the methodjava.lang.Class<?>getType()Returns the return type of the methodinthashCode()java.lang.ObjectinvokeExplosively(java.lang.Object target, java.lang.Object... params)Returns the result of invoking this method ontargetwith parametersparams.booleanisPublic()Returns true if this method is public, false if notbooleanisShadowedBy(FrameworkMethod other)booleanisStatic()Returns true if this method is static, false if notbooleanproducesType(java.lang.reflect.Type type)Deprecated.This is used only by the Theories runner, and does not use all the generic type info that it ought to.voidvalidateNoTypeParametersOnArgs(java.util.List<java.lang.Throwable> errors)voidvalidatePublicVoid(boolean isStatic, java.util.List<java.lang.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, java.util.List<java.lang.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).
-
-
-
Method Detail
-
getMethod
public java.lang.reflect.Method getMethod()
Returns the underlying Java method
-
invokeExplosively
public java.lang.Object invokeExplosively(java.lang.Object target, java.lang.Object... params) throws java.lang.ThrowableReturns the result of invoking this method ontargetwith parametersparams.InvocationTargetExceptions thrown are unwrapped, and their causes rethrown.- Throws:
java.lang.Throwable
-
getName
public java.lang.String getName()
Returns the method's name- Specified by:
getNamein classFrameworkMember<FrameworkMethod>
-
validatePublicVoidNoArg
public void validatePublicVoidNoArg(boolean isStatic, java.util.List<java.lang.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, java.util.List<java.lang.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).
-
isStatic
public boolean isStatic()
Returns true if this method is static, false if not- Specified by:
isStaticin classFrameworkMember<FrameworkMethod>
-
isPublic
public boolean isPublic()
Returns true if this method is public, false if not- Specified by:
isPublicin classFrameworkMember<FrameworkMethod>
-
getReturnType
public java.lang.Class<?> getReturnType()
Returns the return type of the method
-
getType
public java.lang.Class<?> getType()
Returns the return type of the method- Specified by:
getTypein classFrameworkMember<FrameworkMethod>
-
validateNoTypeParametersOnArgs
public void validateNoTypeParametersOnArgs(java.util.List<java.lang.Throwable> errors)
-
isShadowedBy
public boolean isShadowedBy(FrameworkMethod other)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
producesType
@Deprecated public boolean producesType(java.lang.reflect.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 java.lang.annotation.Annotation[] getAnnotations()
Returns the annotations on this method
-
getAnnotation
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annotationType)
Returns the annotation of typeannotationTypeon this method, if one exists.
-
-