say*_*kou 4 gradle kotlin kotlin-multiplatform mockk
我无法将通用模拟库 (mockk.io) 与 kotlin 多平台一起使用。在他们的网站上,它说要在 kotlin 多平台中使用 mockk,你只需要将这一行添加到你的 gradle 中。testImplementation "io.mockk:mockk-common:{version}"
我添加了它并且它正常构建,只有当我想使用它时它才会失败。给予
Unresolved reference: io
Unresolved reference: mockk
Run Code Online (Sandbox Code Playgroud)
我的 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")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1634 次 |
| 最近记录: |