Class MethodInvocation
java.lang.Object
org.spockframework.runtime.extension.MethodInvocation
- All Implemented Interfaces:
IMethodInvocation
- Author:
- Peter Niederwieser
-
Constructor Summary
ConstructorsConstructorDescriptionMethodInvocation(FeatureInfo feature, IterationInfo iteration, Object sharedInstance, Object instance, Object target, MethodInfo method, Object[] arguments) -
Method Summary
Modifier and TypeMethodDescriptionObject[]Returns the arguments for this method invocation.Returns the feature which this method invocation belongs to (if any).Returns theSpecificationinstance for the current iteration.Return the iteration which this method invocation belongs to (if any).Returns the method invoked by this method invocation.Returns theSpecificationinstance for@Sharedfields.getSpec()Returns the specification which this method invocation belongs to.Returns the target (receiver) of this method invocation.voidproceed()Proceeds with the method call.voidsetArguments(Object[] arguments) Sets the arguments for this method invocation.
-
Constructor Details
-
MethodInvocation
public MethodInvocation(FeatureInfo feature, IterationInfo iteration, Object sharedInstance, Object instance, Object target, MethodInfo method, Object[] arguments)
-
-
Method Details
-
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
Description copied from interface:IMethodInvocationReturns the feature which this method invocation belongs to (if any). Differs fromMethodInfo.getFeature()in that it reflects the dynamic picture. For example, when a setup method is invoked, this method will return the corresponding feature, whereasMethodInfo.getFeature()will returnnull.- Specified by:
getFeaturein interfaceIMethodInvocation- Returns:
- the feature which this method invocation belongs to
-
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
-
getInstance
Description copied from interface:IMethodInvocationReturns theSpecificationinstance for the current iteration. For methods that operate in a@Sharedcontext (e.g.setupSpec), this method returns the same value asIMethodInvocation.getSharedInstance().- Specified by:
getInstancein interfaceIMethodInvocation- Returns:
- the
Specificationinstance for the current iteration
-
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.Note that the target of the method invocation may not necessarily be the
Specificationinstance. That's why in most cases, it's more appropriate to use#getInstance.- Specified by:
getTargetin interfaceIMethodInvocation- Returns:
- the target (receiver) of this method invocation
-
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
Description copied from interface:IMethodInvocationReturns the arguments for this method invocation.- Specified by:
getArgumentsin interfaceIMethodInvocation- Returns:
- the arguments for this method invocation
-
setArguments
Description copied from interface:IMethodInvocationSets the arguments for this method invocation.- Specified by:
setArgumentsin interfaceIMethodInvocation
-
proceed
Description 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:
Throwable- any exception thrown by the method call
-