Skip to content

Conversation

bric3
Copy link
Contributor

@bric3 bric3 commented Dec 22, 2016

Following discussion in #838 it is sensible to add a mockito matcher that can take a Pattern as an argument.

The usage is the same as matches(String).

when(mock.oneArg(matches(Pattern.compile("[a-z]+\\d\\d")))).thenReturn(...);

Although it allows to build more complex regex, especially with regular expression flags.

@bric3
Copy link
Contributor Author

bric3 commented Dec 22, 2016

@mockito/core Since the PR is fairly in scope amd fairly straightforward limited I'll merge it right away.

@bric3 bric3 merged commit 1193d14 into release/2.x Dec 22, 2016
@bric3 bric3 deleted the adds-pattern-matcher branch December 22, 2016 13:58
@bric3 bric3 removed the in progress label Dec 22, 2016
@mockitoguy
Copy link
Member

@mockito/core Since the PR is fairly in scope amd fairly straightforward limited I'll merge it right away.

Absolutely.

Updating the public API needs review from other team mates but in this case it's best to move fast. It's an overloaded method, very natural complement to the existing one. Thanks @bric3!

@bric3
Copy link
Contributor Author

bric3 commented Dec 22, 2016

Yes exactly :)

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

Successfully merging this pull request may close these issues.

2 participants