Hello, I'm trying to do mocking in a multiplatform...
# multiplatform
a
Hello, I'm trying to do mocking in a multiplatform project (jvm, native, common), what is a framework that works well for you guys and if possible works well with kotest. I'm trying out
org.kodein.mock.mockmp
, tests and mocking works but building the project fails
The provided plugin com.google.devtools.ksp.KotlinSymbolProcessingComponentRegistrar is not compatible with this version of compiler
so I'm not sure if it's the best framework for now. Any thoughts?
b
For mpp i generally use stubs and fakes instead of mocking. However mockmp and mockk are your best bets if you must stick to mocking.
Since mockmp uses ksp under the hood, you must align ksp and kotlin versions in your project. This is because ksp relies on kotlin compiler plugin api which is as of now unstable and undocumented.
I recommend applying ksp plugin yourself to make it easier to manage and align versions
1
a
I used Mockk for our jvm project but from my understanding Mockk does not work with native correct? Also regarding KSP, do you know where I can find which kotlin version it supports?
b
Ksp version contains kotlin version used e.g. 1.6.21-1.0.1
As for mockk, I think it's jvm/js only
m
Lack of strong mocking support across runtimes is my single biggest bug bear with multiplatform. It was one of the first things I searched for when I started using Kotlin ~8 years ago and I'm surprised serious resources haven't been dedicated to it yet.
m
I’ve been using Mockative: https://github.com/mockative/mockative
m
Both mockative and mockmp are missing features like mocking abstract classes, etc. I know, generally, using interfaces is better but at the same time, it would be very nice to have a batteries-included, do-it-all mock tool like
mockk
(which I love) but multiplatform.
a
Is mockative still maintained? 👀
m
It is a good question. I am not sure. Last release for mockative was Jan 6 with no commits since then.
m
Unfortunately does look pretty inactive, the maintainer was at least previously active here. I hope everything is fine
n
Hi all 👋! Thank you for your patience. I had been putting off updating Mockative for a long while now, so this update was well overdue. This update contains a number of improvements for maintenance, while addressing the bugs and shortcomings reported by the community. I expect to address bugs and update Mockative much faster going forward, so we can all have a reliable mocking framework for Kotlin/Multiplatform.
🦜 2
a
Thanks @Nicklas Jensen, just convinced myself to try Mockative after a pretty bad experience with mocks on native using mockmp. I gotta say that I'm VERY impressed by Mockative, being able to get started quickly and see a running test is super important and I was able to follow the doc and get running in minutes. Thank you, this just skyrockets our testing ability for Kotlin/Multiplatform.
😊 1
501 Views