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

Fix #2915 Forbid spy on mocked interface #2989

Merged

Conversation

bmaggi
Copy link
Contributor

@bmaggi bmaggi commented Apr 25, 2023

A proposition of implementation for 2915

I only raise exception for interface since it's working with class.

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use MockUtil.isMock instead and block both interfaces and classes. Spying on mocks was never supported and this is a safe change to make imo. Blocking only interfaces does not make sense to me, we should block all mocks.

@bmaggi bmaggi force-pushed the feature/forbid_spy_on_mocked_interface branch 2 times, most recently from 9016fd8 to 6695284 Compare April 28, 2023 12:42
@bmaggi
Copy link
Contributor Author

bmaggi commented Apr 28, 2023

I changed the code forbid all mocks

@bmaggi bmaggi force-pushed the feature/forbid_spy_on_mocked_interface branch from 6695284 to 696758b Compare May 2, 2023 16:01
@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: -0.32 ⚠️

Comparison is base (f9fbf50) 85.70% compared to head (696758b) 85.39%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2989      +/-   ##
============================================
- Coverage     85.70%   85.39%   -0.32%     
- Complexity     2865     2869       +4     
============================================
  Files           325      325              
  Lines          8696     8723      +27     
  Branches       1074     1078       +4     
============================================
- Hits           7453     7449       -4     
- Misses          966      992      +26     
- Partials        277      282       +5     
Impacted Files Coverage Δ
src/main/java/org/mockito/Mockito.java 96.62% <ø> (+0.07%) ⬆️

... and 13 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@TimvdLippe TimvdLippe merged commit 7c3641b into mockito:main May 3, 2023
12 of 13 checks passed
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.

None yet

3 participants