https://kotlinlang.org logo
Title
w

wasyl

10/22/2020, 8:29 PM
I can’t seem to be able to enable logging for Kotest 😕 Any idea what I may be missing? I want to see logs in console when running tasks, I tried: • setting
systemProp.KOTEST_DEBUG=true
in
gradle.properties
tasks.withType(Test) { systemProperty("KOTEST_DEBUG", true) }
• exporting KOTEST_DEBUG env variable in console • passing -DKOTEST_DEBUG=true in ./gradlew params
Tests definitely run as I also have
outputs.upToDateWhen { false }
for them, also I see them running
s

sam

10/22/2020, 8:32 PM
I couldn't get it to work yesterday either, it seems to sometimes pass sys props through and other times not
if you can do
export KOTEST_DEBUG=true
then it should set that env in all forked processes too
w

wasyl

10/22/2020, 8:33 PM
Shoot, that’s why you just changed
enabled() = true
? 😄 I did export
KOTEST_DEBUG
, no luck 😞
s

sam

10/22/2020, 8:34 PM
yes that's why I changed it when I was testing lol
it still didn't work properly
I think gradle is just not logging the output, rather than the flag not being set
gradle is capturing std out and is suopposed to be redirecting it to the file
And you need all this too
tasks.named<Test>("jvmTest") {
   useJUnitPlatform()
   filter {
      isFailOnNoMatchingTests = false
   }
   testLogging {
      showExceptions = true
      showStandardStreams = true
      events = setOf(TestLogEvent.FAILED, TestLogEvent.PASSED)
      exceptionFormat = TestExceptionFormat.FULL
   }
}
w

wasyl

10/22/2020, 8:36 PM
showStandardStreams = true
that’s the fix, I think Gradle starts redirecting
System.out
as soon as
test
task starts 🙄
s

sam

10/22/2020, 8:37 PM
does it work now ?
w

wasyl

10/22/2020, 8:41 PM
Yep 🙂 This is enough:
allprojects {
  tasks.withType(Test) {
    systemProperty("KOTEST_DEBUG", true)
    testLogging {
      showStandardStreams = true
    }
  }
}
s

sam

10/22/2020, 8:41 PM
perf
should update the docs
w

wasyl

10/22/2020, 8:42 PM
I wonder if you can somehow get ahold of the real system out 🤔
s

sam

10/22/2020, 8:42 PM
gradle is a funny bastard, doesn't like you doing lots of things
had loads of issues writing the kotest gradle plugin
w

wasyl

10/22/2020, 8:45 PM
Fyi there’s Gradle Community Slack which is quite active 🙂 Useful if you’re stumped on some Gradle stuff and need to ask for guidance
s

sam

10/22/2020, 8:46 PM
oh I didn't know that