Class 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
  • Field Details

    • method

      private final Method method
  • Constructor Details

    • FrameworkMethod

      public FrameworkMethod(Method method)
      Returns a new FrameworkMethod for method
  • Method Details

    • getMethod

      public Method getMethod()
      Returns the underlying Java method
    • invokeExplosively

      public Object invokeExplosively(Object target, Object... params) throws Throwable
      Returns the result of invoking this method on target with parameters params. InvocationTargetExceptions thrown are unwrapped, and their causes rethrown.
      Throws:
      Throwable
    • getName

      public String getName()
      Returns the method's name
      Specified by:
      getName in class FrameworkMember<FrameworkMethod>
    • validatePublicVoidNoArg

      public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors)
      Adds to errors 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 to errors 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()
      Specified by:
      getModifiers in class FrameworkMember<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:
      getType in class FrameworkMember<FrameworkMethod>
    • getDeclaringClass

      public Class<?> getDeclaringClass()
      Returns the class where the method is actually declared
      Specified by:
      getDeclaringClass in class FrameworkMember<FrameworkMethod>
    • validateNoTypeParametersOnArgs

      public void validateNoTypeParametersOnArgs(List<Throwable> errors)
    • isShadowedBy

      public boolean isShadowedBy(FrameworkMethod other)
      Specified by:
      isShadowedBy in class FrameworkMember<FrameworkMethod>
    • isBridgeMethod

      boolean isBridgeMethod()
      Specified by:
      isBridgeMethod in class FrameworkMember<FrameworkMethod>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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 to type
    • getParameterTypes

      private Class<?>[] getParameterTypes()
    • getAnnotations

      public Annotation[] getAnnotations()
      Returns the annotations on this method
    • getAnnotation

      public <T extends Annotation> T getAnnotation(Class<T> annotationType)
      Returns the annotation of type annotationType on this method, if one exists.
    • toString

      public String toString()
      Overrides:
      toString in class Object