I’m trying to get started with writing some unit t...
# multiplatform
g
I’m trying to get started with writing some unit tests for my KMM code but feel a little lost. This is my requirements/wish list. 1. I only need to test the common kotlin code, testing platform specific code is not a requirement. 2. I want to be able to mock interfaces (no weird static mocking or anything like that) 3. It needs to work with kotlin 2.0 4. Preferable it should interfere with the build process as little as possible, it’s too complex already without having another plugin generating code. 5. It should preferable be simple to integrate in a CI flow (GitHub). I’ve looked into kotest which I though seemed really nice syntax-wise until I found out it doesn’t support Kotlin 2.0. If anyone have done this research already and could provide me with some pointers I’d be very happy.
d
Hey Gustav 😊 How important is 'mocking' here; if it's only interfaces you want to mock, can you instead create 'fake' implementations of them in
commonTest
? Then I would recommend using
kotlin.test
for common code annotations and assertions.
g
It’s an option but I think using fakes would add a lot of overhead to writing tests. I’d prefer to have a convenient mocking tool like Mockito where I can simply mock the response of a single method instead of having to implement a fake for a complete interface.
👍 1
I’ve tested `kotlin.test`and that works just fine. If I only had something like Mockito on top of it that would be good enough.
d
You can try Mokkery for mocking
👍 3
👍🏻 1