我正在尝试使用Gradle从Kotlintest获得分层测试报告。我看过一些截图,但是,我没有运气。对于任何类型的测试(FunSpec、WordSpec、BehaviorSpec等),我总是只看到类名,然后是“叶”测试。
样本测试类
import io.kotlintest.matchers.string.shouldStartWith
import io.kotlintest.specs.FunSpec
class HierarchicalTest : FunSpec({
context("Here is a context 1") {
test("Test 1") {
"abc".shouldStartWith("a")
}
}
context("Here is a context 2") {
test("Test 2") {
"abc".shouldStartWith("b")
}
}
})build.gradle
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.41'
}
sourceCompatibility = 1.8
repositories {
jcenter()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.4.2'
testImplementation 'org.junit.platform:junit-platform-engine:1.5.2'
}
test {
useJUnitPlatform()
}IntelliJ结果

分级报告

要在报告中显示context级别,我需要做什么?
发布于 2019-10-04 07:01:07
我在Idea 2018.3.2,我重新创建了项目与你的来源,对我来说,它的工作。我猜这种行为与您运行测试的方式有关。因为我通过Idea运行测试,这是用于测试的绿色箭头。

我想你是通过gradle任务来进行测试的吧?如果是这样的话,Idea可以以不同的方式显示结果--这就是我通过IDEA中的gradle插件运行gradle测试任务时的样子。

https://stackoverflow.com/questions/58057668
复制相似问题