
I looked on the internet and found some examples of how to overcome this.

I have used this library on a large project with many thousand of tests and as I updated the version of the library used different tests failed even before we started using the library.Initially this library depended on a specific version of Kotlin and Mockito, later versions have removed the dependency on Kotlin however I am guessing that testing every combination is not possible. Mockito-Kotlin extensions are fairly easy and fun to use - they introduce DSL for mocks and stubs, increasing readability and helping avoid long complex mock configurations in test suite.There is no benefit here as we can overcome this issue with less than 10 lines of code. I prefer not to take a dependency unless there is a significant benefit.:mockito-kotlin is a library that provides helpful functions for working with Mockito. One possible solution would be to use a library like mockito-kotlin. Using Mockito in a Kotlin project requires some extra dependencies for the following reasons: Kotlin classes are final by default and cannot be mocked by Mockito, hence the need for :mockito-inline. If the method being matched is written in Java then I think that it will work as all Java objects are implicitly nullable. This is because it can return void and this is not assignable to a non-nullable parameter.

If you have a method written in kotlin that does not take a nullable parameter then we cannot match with it using Mockito.any().

Getting matchers to work with Kotlin can be a problem. Using kotlin and mockito together throws up some interesting problems, I have already looked at some of these. I have been using Mockito for a while and recently I have started a kotlin project.
