FrameworkMethod (JUnit API)
Date: 2018-08-04

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 and Description
    `FrameworkMethod(java.lang.reflect.Method method)` Returns a new `FrameworkMethod` for `method`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)`
    `<T extends java.lang.annotation.Annotation> T` | `getAnnotation(java.lang.Class<T> annotationType)` Returns the annotation of type `annotationType` on this method, if one exists.
    `java.lang.annotation.Annotation[]` | `getAnnotations()` Returns the annotations on this method
    `java.lang.Class<?>` | `getDeclaringClass()` Returns the class where the method is actually declared
    `java.lang.reflect.Method` | `getMethod()` Returns the underlying Java method
    `protected int` | `getModifiers()`
    `java.lang.String` | `getName()` Returns the method's name
    `java.lang.Class<?>` | `getReturnType()` Returns the return type of the method
    `java.lang.Class<?>` | `getType()` Returns the return type of the method
    `int` | `hashCode()`
    `java.lang.Object` | `invokeExplosively(java.lang.Object target, java.lang.Object... params)` Returns the result of invoking this method on `target` with parameters `params`.
    `boolean` | `isShadowedBy(FrameworkMethod other)`
    `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.
    `java.lang.String` | `toString()`
    `void` | `validateNoTypeParametersOnArgs(java.util.List<java.lang.Throwable> errors)`
    `void` | `validatePublicVoid(boolean isStatic, java.util.List<java.lang.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`).
    `void` | `validatePublicVoidNoArg(boolean isStatic, java.util.List<java.lang.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`).

    - ### Methods inherited from class org.junit.runners.model.FrameworkMember

      `isPublic, isStatic`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FrameworkMethod

          public FrameworkMethod(java.lang.reflect.Method method)

      Returns a new `FrameworkMethod` for `method`

  - ### 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.Throwable

      Returns the result of invoking this method on `target` with parameters `params`. `InvocationTargetException`s thrown are unwrapped, and their causes rethrown.
      Throws:
        `java.lang.Throwable`

    - #### getName

          public java.lang.String getName()

      Returns the method's name
      Specified by:
        `getName` in class `FrameworkMember<FrameworkMethod>`

    - #### validatePublicVoidNoArg

          public void validatePublicVoidNoArg(boolean isStatic,
                                     java.util.List<java.lang.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,
                                java.util.List<java.lang.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 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:
        `getType` in class `FrameworkMember<FrameworkMethod>`

    - #### getDeclaringClass

          public java.lang.Class<?> getDeclaringClass()

      Returns the class where the method is actually declared
      Specified by:
        `getDeclaringClass` in class `FrameworkMember<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:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.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 to `type`

    - #### 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 type `annotationType` on this method, if one exists.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`