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

Implement VerificationMode times #49 #174

Conversation

Tenkei
Copy link

@Tenkei Tenkei commented Jan 16, 2020

Description
This PR adds the verification mode times() for mock verification described in this issue #49:
Verify times 2 on mock that mock.getPerson(1) was called

, we can also add a wide scope verification mode:
Verify mode times(2) on mock that mock.getPerson(1) was called

P.s: I know it doesn't have the best syntax but performance-wise it's the best approach, alternatively we can try to curry the verify method but it creates a lot of overhead.

Checklist

  • I've added my name to the AUTHORS file, if it wasn't already present.

@Tenkei Tenkei changed the title Implement VerificationMode times Implement VerificationMode times #49 Jan 17, 2020
@MarkusAmshove
Copy link
Owner

Hi, I would be willing to merge this PR, since I'm okay with your provided syntax :-)

Just some thoughts as I'm not able to have a try myself currently:

Verify(5.times) on ...
Verify 5.times on ...

but I'm not sure if those are possible, not too hard to implement or discoverable enough for the user.

Let me know if you want me to merge it :)

@Tenkei
Copy link
Author

Tenkei commented Jan 20, 2020

Hi @MarkusAmshove regarding your suggestion, I believe that Verify(5.times) kind of break the convention being a function, let's say it's not Kluent ;p
As for Verify 5.times on sadly it's not possible. Essentially we want to capture an argument - an int - so we need an infix function. So to add this feature we have to add at least 2 segments.

P.S: I was also a little concerned about discovery, but it seems IntelliJ doing a good job suggesting times and on whenever you use Verify keyword, alternatively we can add a specific keyword for verification so only times is suggested but I like this way of leaving verification mode optional ^^

@Tenkei
Copy link
Author

Tenkei commented Jan 20, 2020

So to wrap it up, let me know if you want to add these extra features:
1- Verification mode:
Verify mode times(2) on mock that mock.getPerson(1) was called
1.2- Extension function for times verification mode
Verify mode 2.times on mock that mock.getPerson(1) was called
2- Specific keyword for verifying via a verification mode
VerifyMultipleCalls times 2 on mock that mock.getPerson(1) was called
or
VerifyVia mode 2.times on mock that mock.getPerson(1) was called

@Tenkei Tenkei force-pushed the feature/issue-49-implemnent-verification-mode-times branch from 83691ae to be463c6 Compare January 20, 2020 02:50
@MarkusAmshove
Copy link
Owner

Alright, I thought that it doesn't work as you said, because I remember trying it out back then :-)
I'm happy with your current solution
Verify times 2.

Are here any features left from mickito that you would like to add (e.g. Verify atLeastTimes 2, if that's a feature)?

Otherwise let me know when you're ready to have it merged :-)

@Tenkei
Copy link
Author

Tenkei commented Jan 27, 2020

@MarkusAmshove Please merge this one, I will create separate Pull requests for every feature so we can discuss/merge them individually.

@MarkusAmshove MarkusAmshove merged commit 8f98e79 into MarkusAmshove:master Jan 29, 2020
@MarkusAmshove
Copy link
Owner

This is now part of v1.60

MarkusAmshove added a commit that referenced this pull request Mar 3, 2020
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

Successfully merging this pull request may close these issues.

2 participants