Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Using verify with a parameter that is a Map or Iterable should be supported #15

Closed
matanlurey opened this issue Jun 30, 2015 · 5 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@matanlurey
Copy link
Contributor

For example:

myService.update(cssClasses: ['a', 'b])

Should match

verify(myService.update(cssClasses: ['a', 'b']))

(Even though the cssClasses List instance is different)

@TedSander
Copy link
Contributor

So this is actually possible today but maybe the interface isn't as nice as it could be. This is how you can do it:

verify(myService.update(cssClasses: argThat(equals(['a', 'b']))))

argThat allows you to specify matchers. This is nice because then do can do shallow equals, unordered equals, contains, etc.

Here is the fall through code:
https://github.com/fibulwinter/dart-mockito/blob/master/lib/mockito.dart#L168

It looks like @fibulwinter was using identical at one time for the matcher, but then removed it. I'm not sure if there was a specific reason of moving away from the matcher. Maybe just for simplicity.

Probably easy enough to switch to equals matcher if there isn't a specific reason for the current pattern.

@fibulwinter
Copy link
Contributor

The root problem is dart-lang/sdk#2217. To counter this I wanted to use equality matcher by default, but I vaguely remember that there were some complications... Stay tuned.

@matanlurey
Copy link
Contributor Author

Ack, the workaround is good enough for today, but I would like to use equals if it is OK.

@fibulwinter: It looks like dart-lang/sdk#2217 is long solved, we commonly use the equals matcher in practically every unit test without issue.

@mockturtl
Copy link

+1 for defaulting to equals, with argThat(same(x)) for when identity matters.

@fibulwinter
Copy link
Contributor

Done in 0.11.0 - equals matcher is used by default.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed bug labels Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants