A copy of my StackOverflow question.
I just want to see the output from a few simple println(...)
in my Kotlin mulitplatform commonTest
code. My build.gradle.kts
looks a little like:
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform") version "1.3.61"
kotlin("plugin.serialization") version "1.3.61"
}
kotlin {
sourceSets {
val commonMain by getting { ... }
val commonTest by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-common")
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
}
}
val jvmMain by getting { ... }
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
// and so on ...
}
}
Meanwhile in ~/src/commonTest/kotlin/my/company/library/CommonTest.kt
:
package my.company.library
import kotlin.test.*
class CommonTest() {
@Test
fun testTrue() {
println("Hello, test!")
assertTrue(true)
}
}
For the time being I’m running tests like this
./gradlew jvmTest
I want to see Hello, test!
show up in the terminal. I don’t mind typing a little extra on the command line.
I haven’t been able to get testLogging.showStandardStreams
to work, and I’m not sure how or if it actually interacts with the multiplatform test targets.