https://kotlinlang.org logo
j

jlleitschuh

01/03/2019, 11:28 PM
Has anyone gotten either Junit 4 or Junit 5 to run common tests with Gradle using the
org.jetbrains.kotlin.multiplatform
plugin? It doesn't look like any of my tests are actually being run. This is what I have for my build logic:
Copy code
kotlin.apply {
    targets.add(presets["jvm"].createTarget("jvm"))
    targets.add(presets["js"].createTarget("js"))

    sourceSets {
        operator fun String.invoke(action: KotlinSourceSet.() -> Unit) {
            named(this, action)
        }
        "commonMain" {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
            }
        }

        "commonTest" {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-test-common")
                implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
            }
        }

        "jsMain" {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
            }
        }

        "jvmMain" {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
            }
        }

        "jvmTest" {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-test")
                implementation("org.jetbrains.kotlin:kotlin-test-junit")
            }
        }
    }
}

tasks.withType<Test>().configureEach {
    testLogging {
        events(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.STARTED)
        displayGranularity = 0
        showExceptions = true
        showCauses = true
        showStackTraces = true
        exceptionFormat = TestExceptionFormat.FULL
    }
}