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

FR: add Mockito.timeout(java.time.Duration) and after(java.time.Duration) #1815

Closed
kluever opened this issue Nov 6, 2019 · 4 comments
Closed

Comments

@kluever
Copy link
Contributor

kluever commented Nov 6, 2019

Representing durations as long's is very error prone. We've seen (and fixed) hundreds of unit mismatch bugs inside of Google.

We (Guava) have recently updated most of our public APIs to add java.time.Duration-based overloads. Caffeine and Selenium have done so as well.

Basically, I'd like to see the following APIs added:
Mockito.after(java.time.Duration)
Mockito.timeout(java.time.Duration)

And ideally the long-accepting APIs would be deprecated.

@TimvdLippe
Copy link
Contributor

That would makes sense to me. Feel free to open a PR to add these methods.

@mockito/developers We have a lot of evidence of longs being misused in common API's. Do you have any concerns if we deprecate the after(long) in favor of after(java.time.Duration) (and the same for timeout)?

@kluever
Copy link
Contributor Author

kluever commented Nov 6, 2019

Ideally we'd plumb the Duration all the way through the various layers of Mockito:

  • org.mockito.verification.After
  • org.mockito.verification.Timeout
  • org.mockito.internal.verification.VerificationOverTimeImpl
  • org.mockito.internal.util.Timer

I assume After and Timeout need to maintain backwards compatibility, but the latter 2 are in an internal package - does that mean I don't need to maintain backwards compatibility? Am I free to make breaking changes to those APIs?

@TimvdLippe
Copy link
Contributor

Yes, any API in org.mockito.internal is not included in our semver policy and we are free to change.

@bric3
Copy link
Contributor

bric3 commented Nov 6, 2019

I second that, now that mockito 3 is java 8 based !

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