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

Deep Stubs Incompatible With Mocking Enum #3167

Merged
merged 1 commit into from Nov 29, 2023

Conversation

AndreasTu
Copy link
Contributor

Mockito can't mock abstract enums in Java 15 or later because they are now marked as sealed.
So Mockito reports that now with a better error message.

If a deep stub returns an abstract enum, it uses in the error case now the first enum literal of the real enum.

Fixes #2984

@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (b6554b2) 85.34% compared to head (b4bea3e) 85.33%.

Files Patch % Lines
...on/bytebuddy/InlineDelegateByteBuddyMockMaker.java 37.50% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3167      +/-   ##
============================================
- Coverage     85.34%   85.33%   -0.01%     
  Complexity     2911     2911              
============================================
  Files           334      334              
  Lines          8866     8867       +1     
  Branches       1099     1101       +2     
============================================
  Hits           7567     7567              
- Misses         1007     1008       +1     
  Partials        292      292              

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

@AndreasTu AndreasTu force-pushed the fix_2984 branch 2 times, most recently from a02acef to 10f8b9d Compare November 2, 2023 11:41
build.gradle Outdated Show resolved Hide resolved
@AndreasTu
Copy link
Contributor Author

@TimvdLippe I have fixed your remarks. And I have also moved the spotless code into gradle/spottless.gradle to activate the spotless checks also in the new java21 subproject.

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.

Couple of nits in the test and let's do the spotless work in a different PR and apply to all subprojects. Most likely that will cause a bit more reformatting.

Mockito can't mock abstract enums in Java 15 or later
because they are now marked as sealed.
So Mockito reports that now with a better error message.

If a deep stub returns an abstract enum, it uses in the error
case now the first enum literal of the real enum.

Fixes mockito#2984
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 74633b8 into mockito:main Nov 29, 2023
18 checks passed
@AndreasTu AndreasTu deleted the fix_2984 branch November 29, 2023 11:03
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.

Deep Stubs Incompatible With Mocking Enum
3 participants