Hey folks, (I am new to the channel and I hope thi...
# kotest
b
Hey folks, (I am new to the channel and I hope this is the right place to ask). I am getting this exception when running Kotest on a gradle travis-ci build but not when I run it on my local mac book:
Copy code
UnknownClass.Kotest > UnknownClass.initializationError FAILED
    java.lang.UnsupportedClassVersionError at ClassLoader.java:-2
(see log here). I am using Kotlin 1.6.2 and Kotest 5.10 (see versions here) I am a little unclear how to debug this and any pointers are greatly appreciated.
r
What version of Java are you using on your mac vs on travis?
UnsupportedClassVersionError
would usually imply some sort of JDK mis-match. šŸ¤”
s
Yep, you prob need JDK11+
b
Hi Richard and Sam. My local installation is
Copy code
openjdk 11.0.14 2022-01-18 LTS
OpenJDK Runtime Environment Corretto-11.0.14.9.1 (build 11.0.14+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.14.9.1 (build 11.0.14+9-LTS, mixed mode)
And I think my travis build is jdk 11 too (see config). But Iā€™ll see if I can get more info about travis java installation.
r
Odd, it should be using 11.
Copy code
language: kotlin
jdk:
  - oraclejdk11
(Aside: is there a reason you're using oraclejdk11 and not openjdk11? Most people avoid oracle's JDK for fear of future license issues.)
s
You might have something that is using > 11
Kotest itself is compiled with jdk8, so it works for everyone, but I suspect some library you are using in your test is itself compiled with > 11. https://github.com/kotest/kotest/blob/master/.github/workflows/master.yml#L22-L26
b
Do you think which class could not be loaded is actually not in the error message. I assumed is is the actual class
Kotest
. But maybe that is not correct.
is there a reason youā€™re using oraclejdk11 and not openjdk11
no, no reason. I think I might have copied it carelessly. Thanks for the feedback. Iā€™ll can change it šŸ™‚
s
Kotest is trying to launch your test, that error is being throw and then kotest is dumping out that message. It should give you more details but I suspect somewhere in kotest we don't handle
Throwable
but only
Exception
and that is an
Error
so you don't get much details.
r
@Benni Can you run the job with
--stacktrace
or
--debug
? There's not much info to glean from the default verbosity level. e.g. this error has the detailed message in the stacktrace but not the 'message'. https://github.com/kotest/kotest/issues/2785
s
Also in addition to what @Richard Gomez said, if you add these steps to your github actions workflow, it will upload the entire test report as an artifact and you will see the full stack trace (probably)
Copy code
-  name: Bundle the build report
   if: failure()
   run: find . -type d -name 'reports' | zip -@ -r build-reports.zip

-  name: Upload the build report
   if: failure()
   uses: actions/upload-artifact@master
   with:
      name: error-report
      path: build-reports.zip
b
okay. I think I figured it out and it has nothing to do with kotest. The offending class comes actually from the project itself. Here is what happens: 1. Project classes are getting compiled with JDK 11 2. I am using kotlinx kover coder coverage and for some reason that starts a jdk 8 vm:
Copy code
/usr/lib/jvm/java-8-openjdk-amd64/bin/java -Dcoverage.ignore.private.constructor.util.class=true -Didea.coverage.log.level=error -Didea.new.sampling.coverage=true -Didea.new.tracing.coverage=true -...
This seems like a bug or misconfiguration of kover tool
Thanks Sam and Richard for being patient and pointing me to ā€œhave you tried turning on debug logsā€ šŸ™‚
šŸ˜‚ 1
s
nice catch
If you get kover working and have time, open up a PR for docs on Kotest!
r
I've wasted a lot of time troubleshooting misleading error messages with Maven and Gradle. šŸ˜¢
s
Yes gradle is awful for that
b
okay. I think I figured it out. I need to add jdk 11 explicitly: https://docs.travis-ci.com/user/languages/java/#switching-jdks-to-java-10-and-up-within-one-job