Tips
In this section we present a number of tips that we have collected over the course of using MockK in the real world.
Timeouts #
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
当前内容版权归 Tiger Oakes 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Tiger Oakes .