【发布时间】:2021-04-06 01:39:39
【问题描述】:
我不能在 kotlin 多平台上使用通用模拟库 (mockk.io)。在他们的网站上,它说要在 kotlin multiplatform 中使用 mockk,您只需将此行添加到您的 gradle 中。 testImplementation "io.mockk:mockk-common:{version}"
我添加了它并且它可以正常构建,只有当我想使用它时它才会失败。给予
Unresolved reference: io
Unresolved reference: mockk
我的 gradle 文件
kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
sourceSets {
val nativeMain by getting
val nativeTest by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("io.mockk:mockk-common:1.10.4")
}
}
}
}
【问题讨论】:
标签: kotlin gradle kotlin-multiplatform mockk