Class MethodInvocation
- java.lang.Object
-
- org.spockframework.runtime.extension.MethodInvocation
-
- All Implemented Interfaces:
IMethodInvocation
public class MethodInvocation extends java.lang.Object implements IMethodInvocation
- Author:
- Peter Niederwieser
-
-
Constructor Summary
Constructors Constructor Description MethodInvocation(FeatureInfo feature, IterationInfo iteration, java.lang.Object sharedInstance, java.lang.Object instance, java.lang.Object target, MethodInfo method, java.lang.Object[] arguments)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object[]getArguments()Returns the arguments for this method invocation.FeatureInfogetFeature()Returns the feature which this method invocation belongs to (if any).java.lang.ObjectgetInstance()Returns the Specification instance for the current iteration.IterationInfogetIteration()Return the iteration which this method invocation belongs to (if any).MethodInfogetMethod()Returns the method invoked by this method invocation.java.lang.ObjectgetSharedInstance()Returns the Specification instance for @Shared fields.SpecInfogetSpec()Returns the specification which this method invocation belongs to.java.lang.ObjectgetTarget()Returns the target (receiver) of this method invocation.protected voidinvokeTargetMethod()voidproceed()Proceeds with the method call.
-
-
-
Constructor Detail
-
MethodInvocation
public MethodInvocation(FeatureInfo feature, IterationInfo iteration, java.lang.Object sharedInstance, java.lang.Object instance, java.lang.Object target, MethodInfo method, java.lang.Object[] arguments)
-
-
Method Detail
-
getSpec
public SpecInfo getSpec()
Description copied from interface:IMethodInvocationReturns the specification which this method invocation belongs to.- Specified by:
getSpecin interfaceIMethodInvocation- Returns:
- the specification which this method invocation belongs to
-
getFeature
public FeatureInfo getFeature()
Description copied from interface:IMethodInvocationReturns 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:
getFeaturein interfaceIMethodInvocation- Returns:
- the feature which this method invocation belongs to
-
getIteration
public IterationInfo getIteration()
Description copied from interface:IMethodInvocationReturn 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:
getIterationin interfaceIMethodInvocation- Returns:
- the iteration which this method invocation belongs to
-
getSharedInstance
public java.lang.Object getSharedInstance()
Description copied from interface:IMethodInvocationReturns the Specification instance for @Shared fields.- Specified by:
getSharedInstancein interfaceIMethodInvocation- Returns:
- the Specification instance for @Shared fields
-
getInstance
public java.lang.Object getInstance()
Description copied from interface:IMethodInvocationReturns the Specification instance for the current iteration.- Specified by:
getInstancein interfaceIMethodInvocation- Returns:
- the Specification instance for the current iteration
-
getTarget
public java.lang.Object getTarget()
Description copied from interface:IMethodInvocationReturns the target (receiver) of this method invocation. In case of a static method call, a Class instance is returned.- Specified by:
getTargetin interfaceIMethodInvocation- Returns:
- the target (receiver) of this method invocation
-
getMethod
public MethodInfo getMethod()
Description copied from interface:IMethodInvocationReturns the method invoked by this method invocation.- Specified by:
getMethodin interfaceIMethodInvocation- Returns:
- the method invoked by this method invocation
-
getArguments
public java.lang.Object[] getArguments()
Description copied from interface:IMethodInvocationReturns the arguments for this method invocation.- Specified by:
getArgumentsin interfaceIMethodInvocation- Returns:
- the arguments for this method invocation
-
proceed
public void proceed() throws java.lang.ThrowableDescription copied from interface:IMethodInvocationProceeds with the method call. Always call this method unless you want to suppress the method call.- Specified by:
proceedin interfaceIMethodInvocation- Throws:
java.lang.Throwable- any exception thrown by the method call
-
invokeTargetMethod
protected void invokeTargetMethod() throws java.lang.Throwable- Throws:
java.lang.Throwable
-
-