T
- the type of the argument to be matched, when used with the with(Delegate<T>)
methodpublic interface Delegate<T>
Expectations.result
field or the
Invocations#with(Delegate)
method, allowing test code
to freely define invocation results or argument matching rules, respectively.
The name and parameters of the delegate method must fit one of the following alternatives:
Invocation
.
If said parameter is present, it must be the first one.
At replay time, it will always receive a suitable object representing the associated invocation which happened to
match the recorded expectation.
When used with the result
field, the result of a delegate method execution can be any return value compatible
with the recorded method's return type, or a thrown error/exception.
When used with the with
method, the delegate method must return a boolean
, being true
for a
successfully matched argument or false
otherwise.
At replay time, when the mocked method/constructor is called the corresponding "delegate" method will be called.
The arguments passed to the delegate method will be the same as those received by the recorded invocation during
replay.
Even static
methods in the mocked type can have delegates, which in turn can be static or not.
The same is true for private
, final
, and native
methods.Copyright © 2006-2014. All Rights Reserved.