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
ClassCastException when combining InjectMocks with generified Mock field #2958
Comments
Probably a regression introduced in #2923. @jfrantzius can you please take a look? |
Looking at it... |
That's an interesting somehow recursive construct that I'm surprised the compiler accepts, but then there surely shouldn't be a public class ConcreteJob extends AbstractJob<ConcreteJob> (a class that uses itself as a type parameter for its superclass? 🤯 ) |
jfrantzius
pushed a commit
to jfrantzius/mockito
that referenced
this issue
Apr 2, 2023
jfrantzius
pushed a commit
to jfrantzius/mockito
that referenced
this issue
Apr 3, 2023
Merged
@TimvdLippe WDYT? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When calling
MockitoAnnotations.openMocks(this);
on a class that contains an@InjectMocks
target, a ClassCastException occurs when the target has a field that is generified and provided by one of the mocks in said class.I've attached a Maven project which demonstrates this flaw. Downgrading the Mockito version to
5.1.1
fixes the issue.mockito-5.2.0-bug.zip
The text was updated successfully, but these errors were encountered: