Open Atatorus opened 5 years ago
Related to #307
Caused by autoboxing caveat in Mockito core. Use booleanThat
, intThat
, longThat
etc. instead.
Thanks, that works ! But we have to respect order of arguments :
@Test
fun fun1bisTest() {
whenever(
itest.fun1(b = booleanThat { it }, user = argThat { this.name == "Marcel" })
).thenReturn("OK")
assertEquals("OK", itest.fun1(true, user))
}
@Test
fun fun1terTest() {
whenever(
itest.fun1(user = argThat { this.name == "Marcel" }, b = booleanThat { it })
).thenReturn("OK")
assertEquals("OK", itest.fun1(true, user))
}
fun1bisTest() is ok, but fun1terTest() raise a class cast exception boolean cannot be cast to user. It's a little annoying, we lost the advantage of named call argument regardless of the order. Just be careful...
Hi, if I mock a method with boolean argument, I got NullPointerException. Example with this interface :
Here the test :
fun2Test is ok, but test fun1Test produces NPE. I got same error with Int and Long in place of Boolean.
Is it a bug, or am I doing something wrong ?
I use version 2.0.0-RC2.
Thanks.