mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.09k stars 198 forks source link

Added value class support #522

Open LarsSven opened 6 days ago

LarsSven commented 6 days ago

This MR serves to add support for value classes to Mockito Kotlin. Value classes currently break and there is no easy way around them, many users have had issues with this: https://github.com/mockito/mockito-kotlin/issues/445

This MR adds an anyValueClass() and adds it to the any() and anyOrNull() implementation. I expect I may have done a few things non-optimally as I am not too familiar with Mockito's inner workings, but I look forward to feedback from someone who knows more about Mockito argument matchers than me to help me improve this. I do think it is important to get support for value classes.

TimvdLippe commented 2 days ago

Not sure why, but tests are failing on this PR. Can you please take a look and ensure all tests are passing?

LarsSven commented 2 days ago

I resolved the issues with the tests, it was a relatively obscure issue that had to do with verify not being called for the test where we expected it to error out. I also went ahead and added more tests to test other scenarios like around null vs non-null and nested value classes.