Do you know a good assertions library for Kotlin M...
# announcements
a
Do you know a good assertions library for Kotlin Multiplatform? I've been using AssertJ (https://joel-costigliola.github.io/assertj/) until now, but it only works on the JVM.
1
j
we've been relatively happy with https://github.com/willowtreeapps/assertk on jvm, and looks like it supports multiplatform
👍 1
c
There are a number of different pure-Kotlin assertion libs; some support All support JVM, some support JS, but I’m not aware of any libs that support Kotlin/Native at the moment. Strikt is my preferred choice for JVM only: https://github.com/robfletcher/strikt Atrium supports JVM and JS and has an API similar to Strikt: https://github.com/robstoll/atrium Kotest also has some basic assertions, but it’s also only JVM and JS. I don’t know if you can use these outside of kotest tests, though: https://github.com/kotest/kotest/blob/master/docs/assertions.md
a
thanks, i'll take a look at assertk
s
Kotest assertions are usable in any framework - JUnit, Spock, Kotest itself, Spek, etc. They are also released for all targets - ios, watchos, tvos, jvm, linux, js, jvm, macos, windows https://search.maven.org/search?q=kotest-assertions-core
There are some kotest assertion modules that are JVM only, where the underlying library is JVM only. For example, the JDBC or arrow modules
a
oh, i see
maybe i'll use kotest then
i'll take a look at it as well
ok, assertk is not working at all
i get a weird error when i try to use
assertThat
Copy code
kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
s
you might need kotlin 1.4 for assertk (just guessing, never used it)
a
nvm, i'll try kotest
o
If you're already using Kotlin's IR compiler backend you might want to look at this: https://github.com/bnorm/kotlin-power-assert
a
not yet, but i will soon