Hi everyone! New here (long time Android dev), but super interested in the project. I have a question about your approach to unit testing; how are you guys dealing with the fact that libraries like MockK don’t support Kotlin/Native yet? I’m thinking of moving unit tests for
commonMain
into
androidTest
so I can use mocking libraries, and just test business logic using Kotlin/JVM. Is this a reasonable approach? Anyone care to share their approach?
m
mkrussel
05/25/2022, 2:25 PM
I try to avoid using mocking libraries for my testings and instead hand roll mocks. This has a benefit of being more performant and less fragile.
I typically just use mocking libraries for third party libraries that are final classes.
t
timkranen
05/25/2022, 2:28 PM
That could work, and I’m assuming in this case your third party libraries aren’t included in the common code?
m
mkrussel
05/25/2022, 2:29 PM
normally but if they are then I just live with only testing on one platform.
🙏 1
n
Nicklas Jensen
05/25/2022, 2:39 PM
I wrote Mockative specifically for Kotlin Multiplatform. It allows you to mock any interface much like how you'd mock stuff in MockK, and has gained some traction in the community.
t
timkranen
05/25/2022, 2:43 PM
@Nicklas Jensen I saw this come by, it looks promising. I think I would prefer this over handrolling all the interfaces, Thanks! I’m going to look into it.