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

Yeray Cabello

10/23/2019, 6:54 AM
Hi, I'm trying to mock a static method that takes a
() -> Unit
function as a parameter, but the matchers seem not to be able to get the mocking signature:
Copy code
io.mockk.MockKException: Failed matching mocking signature for

left matchers: [any()]
What am I missing? I know that equality with lambdas can be a nightmare, but can't seem to find documentation on this.
This is the object I'm trying to mock.
Copy code
package mu

import mu.internal.KLoggerFactory


actual object KotlinLogging {
    /**
     * This method allow defining the logger in a file in the following way:
     * val logger = KotlinLogging.logger {}
     */
    actual fun logger(func: () -> Unit): KLogger = KLoggerFactory.logger(func)

    actual fun logger(name: String): KLogger = KLoggerFactory.logger(name)
}
I should have done
mockkObject(KotlinLogging)
thanks.
421 Views