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

Do not pass static mocks to regular listener callback. #1989

Merged
merged 1 commit into from Jul 29, 2020

Conversation

raphw
Copy link
Member

@raphw raphw commented Jul 28, 2020

Does not include static mocks in regular listener logic as it might distort existing mock collectors that do not expect scoped mocks. Fixes #1988.

We have passed Class objects to the listener to indicate a static mock. The class object is of course itself not a regular mock and it's cleaner to create a callback method of it's own. This way, existing listeners remain logically backwards compatible, including our own listener that is used within the JUnit runner (we have only tested the rule, I added a test for the runner, too).

@raphw raphw added the bug label Jul 28, 2020
@raphw raphw self-assigned this Jul 28, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2020

Codecov Report

Merging #1989 into release/3.x will decrease coverage by 0.04%.
The diff coverage is 70.00%.

Impacted file tree graph

@@                Coverage Diff                @@
##             release/3.x    #1989      +/-   ##
=================================================
- Coverage          85.28%   85.23%   -0.05%     
- Complexity          2601     2604       +3     
=================================================
  Files                322      323       +1     
  Lines               7510     7520      +10     
  Branches             898      899       +1     
=================================================
+ Hits                6405     6410       +5     
- Misses               869      873       +4     
- Partials             236      237       +1     
Impacted Files Coverage Δ Complexity Δ
...ito/internal/invocation/InterceptedInvocation.java 76.59% <0.00%> (-5.23%) 25.00 <0.00> (ø)
...mockito/internal/progress/MockingProgressImpl.java 97.72% <100.00%> (+0.16%) 36.00 <3.00> (+3.00)
...va/org/mockito/listeners/MockCreationListener.java 100.00% <100.00%> (ø) 1.00 <1.00> (?)
...ternal/invocation/finder/AllInvocationsFinder.java 87.50% <0.00%> (-12.50%) 4.00% <0.00%> (-1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c56b3a...724619b. Read the comment docs.

…istort existing mock collectors that do not expect scoped mocks. Fixes #1988.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MockitoJUnitRunner causes NPE when using @Mock on MockedStatic fields
3 participants