-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Return completed futures for unstubbed Future/CompletionStage in ReturnsEmptyValues #3727
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
Return completed futures for unstubbed Future/CompletionStage in ReturnsEmptyValues #3727
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3727 +/- ##
=========================================
Coverage 86.45% 86.45%
- Complexity 2984 2987 +3
=========================================
Files 341 341
Lines 9030 9032 +2
Branches 1111 1112 +1
=========================================
+ Hits 7807 7809 +2
Misses 942 942
Partials 281 281 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@TimvdLippe |
TimvdLippe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 nit, the rest LGTM!
| } | ||
|
|
||
| @Test | ||
| public void returnsCompletedFuture_forFuture() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests look good to me. Rather than a separate test suite, can you move them into mockito-core/src/test/java/org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValuesTest.java instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I’ve moved the tests into ReturnsEmptyValuesTest. Thanks for the review!
TimvdLippe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
Looks like this is a breaking change, so maybe worth noting in the release notes (although the minor version bump might already indicate that). |
Fixes #3724
Updated
ReturnsEmptyValues#returnValueForso that for return typesFuture,CompletableFuture, andCompletionStage, Mockito now returnsCompletableFuture.completedFuture(null)instead ofnull.Tests
ReturnsEmptyValuesFutureTestto verify the new default behavior:Future<String>returns a completed future withnullresult.CompletableFuture<Void>returns a completed future that can be joined without exceptions.CompletionStage<Integer>returns a completed stage that can be safely chained.Checklist
including project members to get a better picture of the change
commit is meaningful and help the people that will explore a change in 2 years
./gradlew spotlessApplyfor auto-formatting)Fixes #<issue number>in the description if relevantFixes #<issue number>if relevant