https://kotlinlang.org logo
Title
s

Shervin

04/21/2023, 11:03 AM
Hey all, I'm facing a strange issue, tests pass locally, but fail on Server. In order to fix them, I need to know the issue of course, how ever, the output from server is only:
io.kotest.assertions.AssertionFailedError at MyTest.kt:112
without any extra information about what was the reason. the test that is failing has only one assertion: Line 112 as mentioned in error:
response shouldBe "ok"
1. why this assertion doesn't have more informative output? 2. how can I have a better output? Any idea ?
m

mitch

04/21/2023, 11:58 AM
hey @Shervin have you tried
withClue
? that can be extremely helpful in these circumstances. https://kotest.io/docs/assertions/clues.html
interestingly it should also print out what the value of the response was though.. did you get that?
s

Shervin

04/21/2023, 12:03 PM
Excellent! building on server to see the actual value
strangely no info is printed:
response.asClue {
    it.title shouldBe "ok"
}
m

mitch

04/21/2023, 12:10 PM
hmm..
are you running this with gradle? do you know what your log settings might be?
try adding this
tasks {
  withType<Test> {
    useJUnitPlatform()
    testLogging {
      setExceptionFormat("full")
      setEvents(listOf("passed", "skipped", "failed", "standardOut", "standardError"))
    }
  }
}
and was that kotest 5.6.1 @Shervin?
s

Shervin

04/21/2023, 12:17 PM
do I need to use
useJUnitPlatform()
when I'm using only
io.quarkus:quarkus-junit5
for test runner ?
Kotest version is
5.5.4
m

mitch

04/21/2023, 12:20 PM
oh you’re using quarkus.. I need to recall, I don’t know how kotest integrates for quarkus, but not too sure. hmm I’m not the expert there. How about the logging settings? as in, if you print anything into stdout or to stderr did it print out in the console?
s

Shervin

04/21/2023, 12:24 PM
building on server with your solution to see the effects right now
didn't help right now trying
quarkus.log.category.io.quarkus.test=TRACE
and then I guess this is not a Kotest issue Kotest is probably throwing the error, but Quarkus is swallowing them.
m

mitch

04/21/2023, 1:06 PM
right.. yeah I don’t know too much about quarkus, @Emil Kantis of the top of your head do you have any hints? I remember vaguely seeing an issue about kotest compatibility with Quarkus. would this be related?
e

Emil Kantis

04/21/2023, 1:33 PM
I'm not using Quarkus either, but I think you still need the
useJUnitPlatform()
. It tells Gradle that you're using JUnit as a testing platform and will pick up test results from there.. Kotest integrates with JUnit to provide test results, but Gradle needs to know that it should listen for it
s

Shervin

04/21/2023, 1:56 PM
Thanks @mitch and @Emil Kantis! I am able to read the error, although it's super verbose 😄 FYI: the test was failing because of server time vs local time 😄
e

Emil Kantis

04/21/2023, 1:59 PM
I usually add the gradle plugin
com.adarshr.test-logger
to get prettier console output from Gradle tests
And if a test fails, I make sure to upload the gradle test reports so I can download and look at them, they'll show result, logs, stdout/stderr, etc per test
s

Shervin

04/21/2023, 2:00 PM
interesting! I will give it a try