Return Unit
#
When stubbing a function that returns nothing, MockK provides a few shortcuts.
val logger = mockk<Logger>()
every { logger.log(any()) } returns Unit
every { logger.log(any()) } answers { Unit }
every { logger.log(any()) } just Runs
justRun { logger.log(any()) }
just Runs
is the nicest to use, since its shorter than returns
and answers
and additionally works with coEvery
.
coEvery { logger.log(any()) } just Runs