-
Notifications
You must be signed in to change notification settings - Fork 197
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
Mocking final classes #285
Comments
Use |
I did that but i still get the error. Not sure what else might be missing.
…On Fri, Sep 7, 2018 at 8:04 AM Zak Taccardi ***@***.***> wrote:
Use mock-maker-inline
<https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2#mock-the-unmockable-opt-in-mocking-of-final-classesmethods>
to mock final classes
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#285 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE2GzHVS_DpwxckaJBCCyf61GAqbpXPPks5uYcYpgaJpZM4WcORA>
.
|
Could you create a MWE for your issue? It's always easier to help if you have a bit more details. |
Using |
I started seeing this when upgrading to mockito-kotlin2. I've got
The class that causes it is final, but has no special settings that I know of:
|
try to add <dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<scope>test</scope>
</dependency> to the dependencies |
I have the same error message when mocking JWTVerifier class (Java, not Kotlin), but adding the bytebuddy dependency doesn't solve the issue for me. This seems like a limitation of Mockito (Section 39: https://www.javadoc.io/doc/org.mockito/mockito-core/2.2.7/org/mockito/Mockito.html#Mocking_Final). Is there any way to bypass it?
|
@meganzhao10 A lot has changed since mockito-kotlin 1.5.0. This looks like a problem related to the creation of your Could you please share the test. |
@bohsen This is the test file. I'm able to run the tests successfully in IntelliJ. But
I also included the pom.xml dependencies if that's helpful
|
@meganzhao10 Have you tried including mockito-inline artifact in your dependencies? |
@meganzhao10 If the |
@bohsen You're right that it should have worked. I built a Java container - the test passes with the base image |
@meganzhao10 Maybe share this with the original Mockito project? I'm not sure if their CI test suite tests against java 14, but IMO it would make sense to create an issue on this. |
This looks like it's tracked mockito/mockito#2436 |
Hi,
Kotlin classes are final by default, when i use this library to test kotlin classes, it gives me the following error:
How do i test this? Please assist
The text was updated successfully, but these errors were encountered: