Hi! What is the correct matcher for a parameter Su...
# getting-started
k
Hi! What is the correct matcher for a parameter Supplier<T>?
m
You mean the Kotlin equivalent of a Java
Supplier
? It’s just a lambda type without arguments, returning T. Your function parameter would be:
Copy code
fun <T> myfunc(supplier: () -> T) = ...
k
I am using mockk and trying to use every{} to return a specific value, but I can’t figure out how to match the parameter of the method which is of type Supplier<T>
m
oh okay, there was some context missing in your message… so the type you want is probably
() -> Any?
so you have to use an argument matcher on that, like
any<() -> Any?>()
.
k
Thanks, looks like
any<Supplier<T>>()
does the job
m
yes, that works too