Class MethodInvocation

java.lang.Object
org.spockframework.runtime.extension.MethodInvocation
All Implemented Interfaces:
IMethodInvocation

public class MethodInvocation extends Object implements IMethodInvocation
Author:
Peter Niederwieser
  • Constructor Details

  • Method Details

    • getSpec

      public SpecInfo getSpec()
      Description copied from interface: IMethodInvocation
      Returns the specification which this method invocation belongs to.
      Specified by:
      getSpec in interface IMethodInvocation
      Returns:
      the specification which this method invocation belongs to
    • getFeature

      public FeatureInfo getFeature()
      Description copied from interface: IMethodInvocation
      Returns the feature which this method invocation belongs to (if any). Differs from MethodInfo.getFeature() in that it reflects the dynamic picture. For example, when a setup method is invoked, this method will return the corresponding feature, whereas MethodInfo.getFeature() will return null.
      Specified by:
      getFeature in interface IMethodInvocation
      Returns:
      the feature which this method invocation belongs to
    • getIteration

      public IterationInfo getIteration()
      Description copied from interface: IMethodInvocation
      Return the iteration which this method invocation belongs to (if any). Executing a feature results in at least one but possibly more iterations (e.g. for a data-driven feature).
      Specified by:
      getIteration in interface IMethodInvocation
      Returns:
      the iteration which this method invocation belongs to
    • getSharedInstance

      public Object getSharedInstance()
      Description copied from interface: IMethodInvocation
      Returns the Specification instance for @Shared fields.

      Note that in most cases, it's more appropriate to use the context-aware IMethodInvocation.getInstance().

      Specified by:
      getSharedInstance in interface IMethodInvocation
      Returns:
      the Specification instance for @Sharedfields
    • getInstance

      public Object getInstance()
      Description copied from interface: IMethodInvocation
      Returns the Specification instance for the current iteration. For methods that operate in a @Shared context (e.g. setupSpec), this method returns the same value as IMethodInvocation.getSharedInstance().
      Specified by:
      getInstance in interface IMethodInvocation
      Returns:
      the Specification instance for the current iteration
    • getTarget

      public Object getTarget()
      Description copied from interface: IMethodInvocation
      Returns the target (receiver) of this method invocation. In case of a static method call, a Class instance is returned.

      Note that the target of the method invocation may not necessarily be the Specification instance. That's why in most cases, it's more appropriate to use #getInstance.

      Specified by:
      getTarget in interface IMethodInvocation
      Returns:
      the target (receiver) of this method invocation
    • getMethod

      public MethodInfo getMethod()
      Description copied from interface: IMethodInvocation
      Returns the method invoked by this method invocation.
      Specified by:
      getMethod in interface IMethodInvocation
      Returns:
      the method invoked by this method invocation
    • getArguments

      public Object[] getArguments()
      Description copied from interface: IMethodInvocation
      Returns the arguments for this method invocation.
      Specified by:
      getArguments in interface IMethodInvocation
      Returns:
      the arguments for this method invocation
    • setArguments

      public void setArguments(Object[] arguments)
      Description copied from interface: IMethodInvocation
      Sets the arguments for this method invocation.
      Specified by:
      setArguments in interface IMethodInvocation
    • proceed

      public void proceed() throws Throwable
      Description copied from interface: IMethodInvocation
      Proceeds with the method call. Always call this method unless you want to suppress the method call.
      Specified by:
      proceed in interface IMethodInvocation
      Throws:
      Throwable - any exception thrown by the method call