Skip to main content

Setup

  1. Apply Gradle plugin:
plugins {
kotlin("multiplatform") version "1.9.24" // ...or any other Kotlin plugin
id("dev.mokkery") version "1.9.24-1.7.0"
}
  1. Ensure that your Mokkery version is compatible with Kotlin version. Refer to compatibility section.

  2. Check targets section to make sure that all targets from you multiplatform project are supported.

  3. At this point everything should be fine. In case of Gradle being unable to find dependencies, check missing repositories.

// for runtime dependencies
repositories {
mavenCentral()
}
// for plugin dependencies
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}

Source setsโ€‹

By default, Mokkery is applied to all Kotlin source sets in the project that contain the "Test" phrase. To change this behavior, you can provide a different rule in your Gradle file:

plugins {
id("dev.mokkery")
}

mokkery {
rule.set(ApplicationRule.Listed("jvmTest")) // this rule affects only jvmTest
rule.set(ApplicationRule.MatchesName(Regex("macos.*Test"))) // this rule affects all "macos.*Test" source sets
rule.set { sourceSet -> sourceSet.name.endsWith("Test") } // this rule affects all ".*Test" source sets
}

Targetsโ€‹

โœ… Supported:

You can refer to this file for more details.

Compatibilityโ€‹

Warning Mokkery 2.0.0 pre-releases are not locked to specific Kotlin pre-release and optimistically assume that compiler API is not going to change. However, breaking changes might happen and result in compile-time errors.

Mokkery versionSupported Kotlin versionPlugin version
2.0.0-RC12.0.0-RC2+"2.0.0-RC1"
1.7.01.9.24, 1.9.23"$kotlinVersion-1.7.0"
1.6.11.9.23"$kotlinVersion-1.6.1"
1.6.01.9.23"$kotlinVersion-1.6.0"
1.5.01.9.23, 1.9.22"$kotlinVersion-1.5.0"
1.4.01.9.22, 1.9.21, 1.9.20"$kotlinVersion-1.4.0"
1.3.21.9.22, 1.9.21, 1.9.20"$kotlinVersion-1.3.2"
1.3.11.9.22, 1.9.21, 1.9.20"$kotlinVersion-1.3.1"
1.3.01.9.20, 1.9.10, 1.9.0, 1.8.22, 1.8.21, 1.8.20"$kotlinVersion-1.3.0"
1.2.01.9.0, 1.8.22, 1.8.21, 1.8.20"$kotlinVersion-1.2.0"
1.1.01.9.0, 1.8.22, 1.8.21, 1.8.20"$kotlinVersion-1.1.0"
1.0.11.9.0, 1.8.22, 1.8.21, 1.8.20"$kotlinVersion-1.0.1"