am
11/27/2018, 11:12 AMHey folks I wanted to know how can we capture lamda arguments using argument captor, I am able to do when lamda values contains single value ,but how to cature more than one
Single argument
api.doSomething(function1:(value:String)->Unit){
//doSomeStruff
function1.invoke("SOME_VALUE")
}
Case 1
val mockfunction = mock<((value: String) -> Unit)>()
api.doSomething(mockfuntion)
val captor = argumentCaptor<String>()
verify(mockfunction).invoke(captor.capture)
Case 2:
Can you guys guide me how can we test for than one argument
api.doSomething(function1:(title:String,message:String)->Unit){
//doSomeStruff
function1.invoke("SOME_VALUE","SOME_VALUE")
}
val mockFunction = mock<(title: String, message: String) -> Unit>()
val captor = argumentCaptor<((title: String, message: String) -> Unit)>()
^^ Not sure is this the correct way to do for the above or how to verify the arguments
oleksiyp
11/27/2018, 11:14 AMam
11/27/2018, 11:14 AMoleksiyp
11/27/2018, 11:15 AMam
11/27/2018, 11:20 AMcapture()
is invoked it gets me a function object, this is wrong ,but I do not know how to capture the multiple arguments,thats passed, for actual code it does pass stringsam
11/27/2018, 11:20 AMoleksiyp
11/27/2018, 11:26 AManswers
, not much I think except that