MocKMP

Generates mocks and fakes for testing, utilizing a Kotlin Symbol Processor. Features include helper usage and workaround installation, supporting efficient setup and verification in unit tests.

JVMKotlin/NativeWasmJS
GitHub stars220
Authorskosi-libs
Open issues11
LicenseMIT License
Creation dateover 4 years ago

Last activityabout 1 year ago
Latest release2.0.2 (about 1 year ago)

= MocKMP :icons: font :version: 2.0.0

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

WARNING: Version 2.0 brings compatibility with Kotlin 2.0, but with breaking changes. If you used version 1.17, have a look at the https://kosi-libs.org/mockmp/2.0/migration/1to2.html[Migration Guide].

== Installation

[source,kotlin,subs="verbatim,attributes"]

plugins { kotlin("multiplatform") id("com.google.devtools.ksp") id("org.kodein.mock.mockmp") version "{version}" }

kotlin { // Your Koltin/Multiplatform configuration }

mockmp { onTest { withHelper() } }

== Example

[source,kotlin]

class MyTest : TestsWithMocks() { override fun setUpMocks() = mocker.injectMocks(this)

@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

See https://kosi-libs.org/mockmp/[MocKMP Documentation].

== Supported by

image::https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg[JetBrains logo.,link=https://jb.gg/OpenSourceSupport]

JVMKotlin/NativeWasmJS
GitHub stars220
Authorskosi-libs
Open issues11
LicenseMIT License
Creation dateover 4 years ago

Last activityabout 1 year ago
Latest release2.0.2 (about 1 year ago)

= MocKMP :icons: font :version: 2.0.0

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

WARNING: Version 2.0 brings compatibility with Kotlin 2.0, but with breaking changes. If you used version 1.17, have a look at the https://kosi-libs.org/mockmp/2.0/migration/1to2.html[Migration Guide].

== Installation

[source,kotlin,subs="verbatim,attributes"]

plugins { kotlin("multiplatform") id("com.google.devtools.ksp") id("org.kodein.mock.mockmp") version "{version}" }

kotlin { // Your Koltin/Multiplatform configuration }

mockmp { onTest { withHelper() } }

== Example

[source,kotlin]

class MyTest : TestsWithMocks() { override fun setUpMocks() = mocker.injectMocks(this)

@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

See https://kosi-libs.org/mockmp/[MocKMP Documentation].

== Supported by

image::https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg[JetBrains logo.,link=https://jb.gg/OpenSourceSupport]