question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: `argMatching` with `answers`

See original GitHub issue

Hello,

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 the State and is mocked
  • The execute method is stubbed with answers

My test call the initmethod 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gervaisbcommented, Jan 9, 2020

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

1reaction
bbonannocommented, Jan 9, 2020

I’ll take a look as soon as I can

Read more comments on GitHub >

github_iconTop Results From Across the Web

ArgMatches' get_one cannot downcast f64 - rust
The solution I used was to parse as String and then convert it to a &str : matches.get_one::<String>("arg").map(|s| s.as_str());.
Read more >
Argument parsing - Rust By Example
Check whether given string is the answer. ... match_args do something error: second argument not an integer usage: match_args <string> Check whether given ......
Read more >
mockito-scala
Default Answers. We defined a new type org.mockito.stubbing.DefaultAnswer which is used to configure the default behaviour of a mock when a non ...
Read more >
Argument parsing | Rust by Example
Check whether given string is the answer. ... match_args do something error: second argument not an integer usage: match_args <string> Check whether given ......
Read more >
Message erroneously marked c-format in coreutils.pot from 8.1
TRANSLATORS: A regular expression testing for a negative answer #. ... TRANSLATORS: The placeholder indicates the bug-reporting address ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found