open class Mockable {
open fun testWithEmptyCallback(someString: String, anotherString: String, callback:() -> Unit)
open fun testWithBooleanCallback(someString: String, anotherString: String, callback:(Boolean) -> Unit)
}
Then I do
val mock = mock<Mocable> {
on { testWithEmptyCallback(any(),any(),any()}. then { (it.argmuents.last() as? ()->Unit).invoke()}
on { testWithBooleanCallback(any(),any(),any()}. then { (it.argmuents.last() as? (Boolean)->Unit).invoke(true)}
}
The first invocation with testWithEmptyCallback works just fine
but if the second line is written with testWithBooleanCallback I get the following exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
I have
Then I do
The first invocation with
testWithEmptyCallback
works just fine but if the second line is written withtestWithBooleanCallback
I get the following exception:java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
How to fix it ?