Is there a standard Kotlin-only solutions for para...
# getting-started
b
Is there a standard Kotlin-only solutions for parameterized tests? I normally use JUnit, however since adding Kotlin/JS as a target I'm looking for alternatives that work outside of the JVM. It doesn't seem like kotlin.test has any support for this, which is what I currently use for the few JS-supported tests I have.
e
if you're willing to switch test runners, I believe #kotest has data-driven tests and supports multiplatform. haven't used it myself though
c
If you're trying it right now, note that Kotest currently has an incompatibility issue with the Kotlin plugin, meaning tests results are not reported for JS. Hopefully it gets fixed soon.
a
The feature request for parameterized tests in kotlin.test is here: https://youtrack.jetbrains.com/issue/KT-46899
We spoke about it in this thread: https://kotlinlang.slack.com/archives/C3PQML5NU/p1676110664778949 Did you end up using Kotest @CLOVIS, or did you use your custom expect/actual wrapper for JUnit and the kotlin.test workaround?
c
I'm currently using the expect-actual wrapper for now. I'm planning to extract it into a proper library in the near future, with proper `before`/`after` features based on coroutines (and maybe test parameterization, we'll see)
I'm still using Kotest for assertions.
a
that would be very cool - let me know if I can help 👍
c
The main idea is that `before`can be emulated with coroutines by storing the lambda and executing it lazily when a test starts using that test's coroutine context, at that point it can register its own cleanup. I wrote down a small example how it could look like here, don't hesitate to subscribe to the issue and give ideas of what it could become 🙂
It's inspired by discussing the wrapper solution with a colleague who's very into JUnit, I want an idiomatic Kotlin way to represent nested test suites and test preconditions
b
Thanks for the additional context here, will try to keep an eye on it. I don't think I have the resources to try and make anything too custom for my stuff, but hopefully a stable baseline comes together sooner rather than later. If it becomes a major need may try out your approach @Adam S, kudos for giving that a go.
224 Views