10 months ago
    Hey guys. Funny enough, I also want to announce a new Kotlin/Multiplatform mocking library: Micro-Mock. It uses KSP to generate mocks, and more or less replicates “classic” mocking systems. Here’s a sample:
    class MyTest {
        @set:Mock lateinit var view: View
        @set:Fake lateinit var model: Model
        lateinit var controller: Controller
        val mocker = Mocker()
        @BeforeTest fun setUp() {
            controller = Controller(view = view, firstModel = model)
        @Test fun controllerTest() {
            mocker.on { view.render(isAny()) } returns true
            mocker.verify { view.render(model) }
    The following limitations apply: • Mocking only applies to interfaces • Faking only applies to concrete trees The processor generates: • Mocks of interfaces, allowing to mock behaviour & verify calls. • Fakes of data classes, filling them of nulls, zeros, empty strings, and alike. • Injector for test classes. You’ll find it here : https://github.com/Kodein-Framework/Micro-Mock We are using this in some of our own Multiplatform tests. I hope it will be useful to the community 😉
    Big Chungus

    Big Chungus

    10 months ago
    Hah, I was thinking of writing something just like that recently to unblock MPP mocking 😄 Good job guys, saved me shitloads of time!