【发布时间】:2021-05-23 20:52:50
【问题描述】:
我尝试在我的 Kotlin 多平台项目中使用 Spock 测试框架,但失败了,gradle 脚本:
plugins {
val kotlinVersion = "1.4.30"
kotlin("multiplatform") version kotlinVersion
application
kotlin("plugin.serialization") version kotlinVersion
groovy // for spock
}
repositories {
// ...
maven("https://jitpack.io") // for spock
}
kotlin {
jvm {withJava()}
js {/*...*/}
sourceSets {
val commonMain by getting {
dependencies {/*...*/}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {/*...*/}
}
val jvmTest by getting {
dependencies {
dependsOn(commonTest)
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
// implementation(kotlin("test-junit5"))
// for spock
implementation("org.spockframework.spock:spock-core:spock-1.3")
implementation("org.codehaus.groovy:groovy-all:3.0.7")
}
}
val jsMain by getting {
dependencies {/*...*/}
}
}
}
我用groovy-2.5和Junit5尝试了spock-1.3和spock-2.0-M4,都因依赖问题而失败,即使测试可以运行,它告诉:没有收到测试事件 ,更重要的是:
我不能仅为测试创建 groovy 源文件夹。(该目录类似于普通文件夹,而不是源或测试文件夹)
如何配置依赖或gradle.build.kts文件?非常感谢任何帮助!
【问题讨论】:
标签: kotlin spock kotlin-multiplatform