首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用Kotlintest和Gradle生成分级测试报告

如何用Kotlintest和Gradle生成分级测试报告
EN

Stack Overflow用户
提问于 2019-09-23 07:38:45
回答 1查看 152关注 0票数 1

我正在尝试使用Gradle从Kotlintest获得分层测试报告。我看过一些截图,但是,我没有运气。对于任何类型的测试(FunSpec、WordSpec、BehaviorSpec等),我总是只看到类名,然后是“叶”测试。

  • Gradle 5.6.2
  • Kotlintest 3.4.2
  • JUnit Platform 1.5.2

样本测试类

代码语言:javascript
复制
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

代码语言:javascript
复制
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级别,我需要做什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-04 07:01:07

我在Idea 2018.3.2,我重新创建了项目与你的来源,对我来说,它的工作。我猜这种行为与您运行测试的方式有关。因为我通过Idea运行测试,这是用于测试的绿色箭头。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58057668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档