Skip to content

kosi-libs/MocKMP

Repository files navigation

MocKMP

A Kotlin/Multiplatform Kotlin Symbol Processor that generates Mocks & Fakes.

Built in collaboration with Deezer.

Installation

plugins {
    kotlin("multiplatform")
    id("org.kodein.mock.mockmp") version "1.17.0"
}

kotlin {
    // Your Koltin/Multiplatform configuration
}

mockmp {
    usesHelper = true
    installWorkaround()
}

Example

class MyTest : TestsWithMocks() {
    override fun setUpMocks() = injectMocks(mocker) //(1)

    @Mock lateinit var view: View
    @Fake lateinit var model: Model

    val controller by withMocks { Controller(view = view, firstModel = model) }

    @Test fun controllerTest() {
        every { view.render(isAny()) } returns true
        controller.start()
        verify { view.render(model) }
    }
}

Read more