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

NullPointerException thrown during migration #12

Closed
mustafaozhan opened this issue Jun 22, 2024 · 3 comments
Closed

NullPointerException thrown during migration #12

mustafaozhan opened this issue Jun 22, 2024 · 3 comments

Comments

@mustafaozhan
Copy link

Hello,

Thank you for this amazing mocking library, thanks to it, I get rid of ksp and decreased my build times, also finally I was able to move my project to Kotlin 2.0.

During the migration from Mockative to Mokkery I had various issues and couldn't fix 3 of them. This issue is targeting to one of it.

If you check the linked PR, I have commented out one verify line. This line was working fine with Mockative, I had to comment it during Mokkery migration since it was giving the below error:

    java.lang.NullPointerException at AdControlRepositoryTest.kt:225

You can see the full log in the link I shared below.

Let me know if anything is needed from my end!

Log: https://github.com/Oztechan/CCC/actions/runs/9614886435/job/26546544559?pr=3581
PR: Oztechan/CCC#3581

@lupuuss
Copy link
Owner

lupuuss commented Jun 22, 2024

Hi! The first problem here is that Mokkery does not support call chains. It means that syntax below is not supported

every { dependency.otherDependency.call() } returns Unit
verify { dependency.otherDependency.call() }

You have to perform this operations directly:

val otherDependency = mock<OtherDependency> { every { call() } returns Unit }
every { dependency.otherDependency } returns otherDependency 
verify { otherDependency.call() }

The second problem is that AdConfig is regular instance - not a mock. In result, its calls are not tracked.

PS I see that you keep each call in single verify block. You can move your verifications into single verify block.

@mustafaozhan
Copy link
Author

@lupuuss thank you for the expiation, this one is also resolved together with the other ones 🙂

@lupuuss
Copy link
Owner

lupuuss commented Jun 26, 2024

No problem @mustafaozhan ! Thank you for reporting the issues!

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

No branches or pull requests

2 participants