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

The matcher contains() is misleading #387

Open
gmananton opened this issue May 18, 2022 · 2 comments
Open

The matcher contains() is misleading #387

gmananton opened this issue May 18, 2022 · 2 comments

Comments

@gmananton
Copy link

I found for myself that the matcher name "contains" is a bit misleading. Because it sounds similarly to contains() method of java.util.Collection it may expected to behave like this:
assertThat(List.of(1,2), contains(1))
But the expression above will throw an AssertionError, because contains() is acting like containsExactly().
So how do you think about renaming it?
Unfortunately the obvious problem here - is of course broken back compatibility ( If someone is using this matcher in his tests - they may have been broken and must be refactored

@PakhomovAlexander
Copy link

Hi, after spending quite some time on debugging, I realized that the observed behavior stemmed from this function. That is really confusing.

@Pochatkin
Copy link

Oh guys, I feel your pain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants