1

I'm trying to get a hierarchical test report from Kotlintest using Gradle. I've seen some screenshots allowing it, however, I have no luck. For any type of tests (FunSpec, WordSpec, BehaviorSpec etc) I always see only the class name and then the "leaf" tests.

  • Gradle 5.6.2
  • Kotlintest 3.4.2
  • JUnit Platform 1.5.2

Sample test class

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 result

enter image description here

Gradle report

enter image description here

What do I need to do to have the context level visible in the report?

Piotr Gwiazda
  • 12,080
  • 13
  • 60
  • 91

1 Answers1

0

I'm on Idea 2018.3.2 and I recreated project with your sources and for me it works. I guess this behavious correlates with the way you run tests. Because I ran tests via Idea and it's green arrows for tests.

enter image description here

I guess you run tests via gradle tasks? If so, Idea can show results differently This is how it looks like when I run gradle test task via gradle plugin in IDEA

enter image description here

Eugene Kortov
  • 445
  • 6
  • 17
  • That is right! The Gradle way works without a plugin while for the InteliJ way a plugin kotlintest is needed. If you could edit your answer and let everyone know where the "magic" switch is, that would be perfect! At the same time there is no way to have hierarchy in html report, correct? – Piotr Gwiazda Oct 05 '19 at 14:02