mockito-kotlin icon indicating copy to clipboard operation
mockito-kotlin copied to clipboard

Using Mockito with Kotlin

Results 98 mockito-kotlin issues
Sort by recently updated
recently updated
newest added
trafficstars

Hi all. I guess the problem here is that I am trying to mock value class. If I remove the `value` modifier this code works fine. Do you have any...

After upgrading from Kotlin 1.6.21 to 1.7.0 several tests failed in my project. Error log from 1.7.0: https://github.com/breucode/imisu/runs/7162625396 Successful run in 1.6.21: https://github.com/breucode/imisu/runs/7162750526 The failing tests are located here: https://github.com/breucode/imisu/blob/master/src/test/kotlin/de/breuco/imisu/api/routes/ServicesTest.kt

When returning a value class from a mocked method, class cast can not be done properly Sample code: ``` value class Base64Data(val data: String) ``` ``` fun doSomething(data: Base64Data): Base64Data...

I was trying a mock a static method inside my Kotlin class for a unit test, but it seems the Java version of my Unit Test is successful but the...

Having a kotlin singleton with static methods ``` internal object TestSingleton { @JvmStatic fun staticMethod1 (str: String) { println("+++ === +++ TestSingleton.staticMethod(), $str") staticMethod2 (str) } @JvmStatic fun staticMethod2 (str:...

Adds some additional matchers like `not`, or `leq`. I couldn't be bothered to write tests because the code is so incredibly simple.

I'm not sure whether it's mockito-kotlin as it seems that something is wrong on boundary of kotlin/mockito, however it might be a thing that mockito-kotlin can solve somehow. It seems...

I believe there's a missed opportunity on the `doReturn.when` implementation. Mockito kotlin is only changing reseved word `'when' `with `whenever`, but the implementation is not on par with the rest...

``` fun testHandleCallSuccess() { val call = mock Result>() val callback = Mockito.mock(Callback::class.java) as Callback runBlocking { whenever(call.invoke()).thenReturn(Result.success(0)) baseViewModel.handleCall(call, callback) } verify(callback).success(0) } ``` **whenever(call.invoke()).thenReturn(Result.success(0))** will return null! Is this...

My code: `Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID).toLowerCase()` and I'm trying to mock it ``` Mockito.mockStatic(Settings.Secure::class.java).use { utilities -> utilities.`when` { Settings.Secure.getString(anyVararg(), anyVararg()) }.thenReturn("test") } ``` Error : ``` getString must not be null...