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

Fixes #3077 : Report unused stubbing exceptions when test filter is no-op #3078

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

C0urante
Copy link
Contributor

@C0urante C0urante commented Aug 4, 2023

Fixes #3077

Summary

Adds granularity to the logic that skips reporting of unused stubbings when tests are filtered. Instead of simply detecting the use of any kind of filter, intercepts uses of that filter and only skips reporting of unused stubbings when the filter actually prevents one or more tests from being run.

This allows filters (such as JUnit category excludes, which themselves can be used to separate unit and integration tests) to be applied during a test run without sacrificing the benefits of strict stubbing.

Testing coverage is added for this newly-handled case (i.e., when a filter does not prevent any tests from being run), as well as existing cases (i.e., when a filter does prevent at least one test from being run).

Checklist

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should mention Fixes #<issue number> if relevant

@codecov-commenter
Copy link

codecov-commenter commented Aug 4, 2023

Codecov Report

Patch coverage: 87.50% and project coverage change: +0.48% 🎉

Comparison is base (f5ad9e9) 84.97% compared to head (c9339f1) 85.46%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3078      +/-   ##
============================================
+ Coverage     84.97%   85.46%   +0.48%     
- Complexity     2874     2889      +15     
============================================
  Files           329      329              
  Lines          8801     8813      +12     
  Branches       1093     1094       +1     
============================================
+ Hits           7479     7532      +53     
+ Misses         1045      994      -51     
- Partials        277      287      +10     
Files Changed Coverage Δ
...ava/org/mockito/internal/runners/StrictRunner.java 93.10% <87.50%> (-1.02%) ⬇️

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Thanks!

@TimvdLippe TimvdLippe merged commit ece6107 into mockito:main Aug 8, 2023
@C0urante
Copy link
Contributor Author

C0urante commented Aug 9, 2023

Thanks @TimvdLippe!

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.

Unused stubbings are not reported when filters are used
3 participants