类 FrameworkMethod
- java.lang.Object
- org.junit.runners.model.FrameworkMember<FrameworkMethod>
- org.junit.runners.model.FrameworkMethod
- 所有已实现的接口:
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.)- 从以下版本开始:
- 4.5
构造器概要
构造器 构造器 说明 FrameworkMethod(Method method)
Returns a newFrameworkMethod
formethod
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 boolean
equals(Object obj)
<T extends Annotation>
TgetAnnotation(Class<T> annotationType)
Returns the annotation of typeannotationType
on this method, if one exists.Annotation[]
getAnnotations()
Returns the annotations on this methodClass<?>
getDeclaringClass()
Returns the class where the method is actually declaredMethod
getMethod()
Returns the underlying Java methodprotected int
getModifiers()
String
getName()
Returns the method's nameClass<?>
getReturnType()
Returns the return type of the methodClass<?>
getType()
Returns the return type of the methodint
hashCode()
Object
invokeExplosively(Object target, Object... params)
Returns the result of invoking this method ontarget
with parametersparams
.boolean
isShadowedBy(FrameworkMethod other)
boolean
producesType(Type type)
已过时。This is used only by the Theories runner, and does not use all the generic type info that it ought to.String
toString()
void
validateNoTypeParametersOnArgs(List<Throwable> errors)
void
validatePublicVoid(boolean isStatic, List<Throwable> errors)
Adds toerrors
if this method: is not public, or returns something other than void, or is static (givenisStatic is false
), or is not static (givenisStatic is true
).void
validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors)
Adds toerrors
if 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
).从类继承的方法 org.junit.runners.model.FrameworkMember
isPublic, isStatic
构造器详细资料
FrameworkMethod
public FrameworkMethod(Method method)
Returns a newFrameworkMethod
formethod
方法详细资料
invokeExplosively
public Object invokeExplosively(Object target, Object... params) throws Throwable
Returns the result of invoking this method ontarget
with parametersparams
.InvocationTargetException
s thrown are unwrapped, and their causes rethrown.- 抛出:
Throwable
getName
public String getName()
Returns the method's name- 指定者:
getName
在类中FrameworkMember<FrameworkMethod>
validatePublicVoidNoArg
public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors)
Adds toerrors
if 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 toerrors
if 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()
- 指定者:
getModifiers
在类中FrameworkMember<FrameworkMethod>
getReturnType
public Class<?> getReturnType()
Returns the return type of the method
getType
public Class<?> getType()
Returns the return type of the method- 指定者:
getType
在类中FrameworkMember<FrameworkMethod>
getDeclaringClass
public Class<?> getDeclaringClass()
Returns the class where the method is actually declared
validateNoTypeParametersOnArgs
public void validateNoTypeParametersOnArgs(List<Throwable> errors)
isShadowedBy
public boolean isShadowedBy(FrameworkMethod other)
producesType
@Deprecated public boolean producesType(Type type)
已过时。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 typeannotationType
on this method, if one exists.