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

NPE when you forget to call mock inside coVerify/verify #107

Open
dalewking opened this issue Apr 30, 2024 · 1 comment
Open

NPE when you forget to call mock inside coVerify/verify #107

dalewking opened this issue Apr 30, 2024 · 1 comment

Comments

@dalewking
Copy link

I have a test where I had a coVerify block and actually forgot to put the call to the method and the error you get is just a NullPointerException. You should detect this and provide a better failure message.

@dalewking
Copy link
Author

I think the same would be true for every/coEvery since the NPE is coming from this line of Mockable.record:

            return receiver!! to invocation!!

both values will be null if there are no calls to a mock. The simple solution is to throw a more intelligent exception/assertion in the try block after calling block

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

1 participant