To use a scripted action in an expectation, statically import the perform method and call it within the
will(...) clause of the expectation.
The script can refer to the parameters of the mocked method by the names $0 (the first parameter), $1, $2, etc, and to the mock object that has been invoked by the name $this. You can define other script variables by calling the action's where method.
allowing (sheep).accept(with(a(Visitor.class))); will(perform("$0.visitSheep($this)");
is equivalent to:
allowing (sheep).accept(with(a(Visitor.class))); will(perform("$0.visitSheep(s)").where("s", sheep);
Public Member Functions
|void||describeTo (Description description)|
|Object||invoke (Invocation invocation) throws Throwable|
|ScriptedAction (String expression)|
|ScriptedAction||where (String name, Object value)|
Static Public Member Functions
|static ScriptedAction||perform (String script)|
Private Member Functions
|void||defineParameters (Interpreter interpreter, Invocation invocation) throws EvalError|
|final Interpreter||interpreter = new Interpreter()|