mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat(test): Integrate Mokkery, Turbine, and Kotest into KMP build logic
This commit is contained in:
parent
79a4e66eb8
commit
b4ba582ff0
5 changed files with 70 additions and 2 deletions
|
|
@ -54,6 +54,7 @@ dependencies {
|
|||
compileOnly(libs.google.services.gradlePlugin)
|
||||
compileOnly(libs.koin.gradlePlugin)
|
||||
implementation(libs.kover.gradlePlugin)
|
||||
implementation(libs.mokkery.gradlePlugin)
|
||||
compileOnly(libs.kotlin.gradlePlugin)
|
||||
compileOnly(libs.ksp.gradlePlugin)
|
||||
compileOnly(libs.androidx.room.gradlePlugin)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class KmpLibraryConventionPlugin : Plugin<Project> {
|
|||
apply(plugin = "meshtastic.spotless")
|
||||
apply(plugin = "meshtastic.dokka")
|
||||
apply(plugin = "meshtastic.kover")
|
||||
apply(plugin = libs.plugin("mokkery").get().pluginId)
|
||||
|
||||
configureKotlinMultiplatform()
|
||||
configureKmpTestDependencies()
|
||||
|
|
|
|||
|
|
@ -114,12 +114,24 @@ internal fun Project.configureKmpTestDependencies() {
|
|||
val commonTest = findByName("commonTest") ?: return@apply
|
||||
commonTest.dependencies {
|
||||
implementation(kotlin("test"))
|
||||
implementation(libs.library("kotest-assertions"))
|
||||
implementation(libs.library("kotest-property"))
|
||||
implementation(libs.library("turbine"))
|
||||
}
|
||||
|
||||
// Configure androidHostTest if it exists
|
||||
val androidHostTest = findByName("androidHostTest")
|
||||
androidHostTest?.dependencies {
|
||||
implementation(kotlin("test"))
|
||||
implementation(libs.library("kotest-assertions"))
|
||||
implementation(libs.library("kotest-property"))
|
||||
implementation(libs.library("turbine"))
|
||||
}
|
||||
|
||||
// Configure jvmTest if it exists
|
||||
val jvmTest = findByName("jvmTest")
|
||||
jvmTest?.dependencies {
|
||||
implementation(libs.library("kotest-runner-junit6"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.meshtastic.core.common
|
||||
|
||||
import dev.mokkery.answering.returns
|
||||
import dev.mokkery.every
|
||||
import dev.mokkery.mock
|
||||
import dev.mokkery.verify
|
||||
import io.kotest.matchers.shouldBe
|
||||
import kotlin.test.Test
|
||||
|
||||
interface SimpleInterface {
|
||||
fun doSomething(input: String): Int
|
||||
}
|
||||
|
||||
class MokkeryIntegrationTest {
|
||||
|
||||
@Test
|
||||
fun testMokkeryAndKotestIntegration() {
|
||||
val mock = mock<SimpleInterface>()
|
||||
|
||||
every { mock.doSomething("hello") } returns 42
|
||||
|
||||
val result = mock.doSomething("hello")
|
||||
|
||||
result shouldBe 42
|
||||
|
||||
verify {
|
||||
mock.doSomething("hello")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,8 @@ kotlinx-datetime = "0.7.1-0.6.x-compat"
|
|||
kotlinx-serialization = "1.10.0"
|
||||
ktlint = "1.7.1"
|
||||
kover = "0.9.7"
|
||||
mockk = "1.14.9"
|
||||
mokkery = "3.3.0"
|
||||
kotest = "6.1.7"
|
||||
testRetry = "1.6.4"
|
||||
turbine = "1.2.1"
|
||||
|
||||
|
|
@ -193,7 +194,11 @@ androidx-test-ext-junit = { module = "androidx.test.ext:junit", version = "1.3.0
|
|||
androidx-test-runner = { module = "androidx.test:runner", version = "1.7.0" }
|
||||
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version = "3.7.0" }
|
||||
junit = { module = "junit:junit", version = "4.13.2" }
|
||||
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
|
||||
mokkery-library = { module = "dev.mokkery:mokkery-runtime", version.ref = "mokkery" }
|
||||
kotest-assertions = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
|
||||
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }
|
||||
kotest-framework = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" }
|
||||
kotest-runner-junit6 = { module = "io.kotest:kotest-runner-junit6", version.ref = "kotest" }
|
||||
robolectric = { module = "org.robolectric:robolectric", version = "4.16.1" }
|
||||
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
|
||||
|
||||
|
|
@ -247,6 +252,7 @@ detekt-gradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plug
|
|||
firebase-crashlytics-gradlePlugin = { module = "com.google.firebase:firebase-crashlytics-gradle", version.ref = "firebase-crashlytics-gradle" }
|
||||
google-services-gradlePlugin = { module = "com.google.gms.google-services:com.google.gms.google-services.gradle.plugin", version.ref = "google-services-gradle" }
|
||||
koin-gradlePlugin = { module = "io.insert-koin.compiler.plugin:io.insert-koin.compiler.plugin.gradle.plugin", version.ref = "koin-plugin" }
|
||||
mokkery-gradlePlugin = { module = "dev.mokkery:mokkery-gradle", version.ref = "mokkery" }
|
||||
kover-gradlePlugin = { module = "org.jetbrains.kotlinx.kover:org.jetbrains.kotlinx.kover.gradle.plugin", version.ref = "kover" }
|
||||
ksp-gradlePlugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "devtools-ksp" }
|
||||
secrets-gradlePlugin = {module = "com.google.android.secrets-gradle-plugin:com.google.android.secrets-gradle-plugin.gradle.plugin", version = "1.1.0"}
|
||||
|
|
@ -269,6 +275,7 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
|
|||
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
|
||||
mokkery = { id = "dev.mokkery", version.ref = "mokkery" }
|
||||
|
||||
# Google
|
||||
devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "devtools-ksp" }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue