bug: `argMatching` with `answers`
See original GitHub issueHello,
I may use this library in an unexpected way but it seems that argMatching
is not working in all cases.
I have a Service
with one method init
and one execute(s:State, p:Parameter)
.
- The
init
method returns theState
and is mocked - The
execute
method is stubbed withanswers
My test call the init
method and then execute
two times and verify that service.execute(*, argMatching({case ExpectedParameterType(_) => })) was called
. However it fail with:
Argument(s) are different! Wanted: service.execute( <any>, argMatching(…) ); -> at example.ServiceSpec.$anonfun$new$4(ServiceSpec.scala:27) Actual invocations have different arguments: service.init(
); -> at example.ServiceSpec.$anonfun$new$3(ServiceSpec.scala:23) service.execute( My mock for State, OtherParameterType(Other) ); -> at example.ServiceSpec.$anonfun$new$3(ServiceSpec.scala:24) service.execute( My mock for State, ExpectedParameterType(Expected) ); -> at example.ServiceSpec.$anonfun$new$3(ServiceSpec.scala:25)
at example.ServiceSpec.$anonfun$new$4(ServiceSpec.scala:27) at example.ServiceSpec.verification(ServiceSpec.scala:7) at example.ServiceSpec.$anonfun$new$3(ServiceSpec.scala:27)
As you can see the second invocation of execute
is the expected one. And the partial function in argMatching
is defined for the argument. Am I doing something wrong ?
Here is a sample project to reproduce it : https://github.com/gervaisb/mockito-scala_191
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Yes, sorry. This was an issue in my sample. My matching is more complex than that, it is a copy-paste error.
The sample project is passing while my real tests are still failing. However the partial function used in
argMatching
is defined for the receive argument… If the partial function is defined and executed, how can it fail ?But because the sample is passing I guess it is an issue on my side. Sorry for the inconvenience
I’ll take a look as soon as I can