使用多平台模拟Kotlin中的通用测试 [英] mock common tests in kotlin using multiplatform
本文介绍了使用多平台模拟Kotlin中的通用测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能使用带有kotlin多平台的通用模拟库(mockk.io).在他们的网站上说,要在kotlin多平台中使用嘲笑,您只需要将此行添加到gradle中即可. testImplementation"io.mockk:mockk-common:{version}"
I can't use the common mock library ( mockk.io ), with kotlin multiplatform. In their website it says that to use mockk in kotlin multiplatform you just need to add this line to your gradle. testImplementation "io.mockk:mockk-common:{version}"
我添加了它并且它可以正常构建,只有当我想使用它时才失败.给予
I added it and it builds normally, only when I want to use it is when it fails. Giving
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 Native上使用嘲笑.
Unless something has changed, mockk does not work on Kotlin Native.
这篇关于使用多平台模拟Kotlin中的通用测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文