我无法将通用模拟库(mockk.io)与 kotlin 多平台一起使用。在他们的网站上,它说要在 kotlin 多平台中使用 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")
}
}
}
}
除非有什么改变,mockk 不能在 Kotlin Native 上工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)