Merged
Conversation
Example failing test for mockito#2656
fixes: mockito#2656
3c15da8 to
d0bf836
Compare
Closed
5 tasks
TimvdLippe
requested changes
Jun 1, 2022
Contributor
TimvdLippe
left a comment
There was a problem hiding this comment.
Some minor changes, but overall looking good!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2659 +/- ##
============================================
+ Coverage 86.22% 86.27% +0.04%
- Complexity 2763 2766 +3
============================================
Files 314 315 +1
Lines 8290 8296 +6
Branches 1031 1031
============================================
+ Hits 7148 7157 +9
+ Misses 873 872 -1
+ Partials 269 267 -2 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: #2656
Release 4.6.0 introduced a new feature #2650 to allow strictness to be set via the
@Mockannotation. Unfortunately, the feature has a bug that results in any test-level strictness setting being ignored, e.g.In the above code the
lenientMockwould actually be strict, as the@Mock'sstrictnessdefaults toSTRICT_STUBS. This default was overriding the test levelLENIENT.To fix the issue the default of the
Mock.strictnessmethod needs to be something meaningnot set, allowing the mock's strictness to be ignored and the test level strictness to be used.Unfortunately, no
no setvalue exists in theStrictnessenum and it is illegal to default tonull. Fixing this in a backwards compatible way would have meant polluting the public API, (e.g. adding aDEFAULTvalue to the existingStrictnessenum, which doesn't make sense in a lot of other places the enum is used). As this feature has only just been released, and is essentially broken, a breaking change is being introduced to fix the issue.BREAKING CHANGE: This PR changes the return value of
Mock.strictness()to a localStrictnessenum value. This will require users to change any code written against 4.6.0 that sets thestrictnessvia the@Mockannotation to change their code.Example code migration:
To:
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
Fixes #<issue number>in the description if relevantFixes #<issue number>if relevant