https://kotlinlang.org logo
#mockk
Title
# mockk
s

svenjacobs

08/14/2019, 1:40 PM
Hi all, how can I mock a function type with MockK?
Copy code
val fn: () -> String? = mockk {
    // not working since "invoke()" clashes with invoke() function from MockK
    every { invoke() } returnsMany "hello", null
}
d

Dias

08/14/2019, 1:56 PM
this@mockk.invoke()
o

oleksiyp

08/14/2019, 2:28 PM
val fn: () -> String? = mockk() every { fn() } returnsMany "hello", null
👍🏼 1
s

svenjacobs

08/14/2019, 2:47 PM
Thanks @oleksiyp, it can be so simple ;)
7 Views