kosi-libs / MocKMP

A mocking processor for Kotlin Multiplatform
https://kosi-libs.org/mockmp
MIT License
184 stars 12 forks source link

Feature Request: Enable mocking for `expect interface` #18

Open ankushg opened 2 years ago

ankushg commented 2 years ago

It would be nice to be able to mock an expect interface with generated mocks for the actual interface for each target 😄

SalomonBrys commented 2 years ago

MocKMP is a test tool. Having a tool that generates actual implementations for expect interfaces is not a test tool and outside the scope of MocKMP.

ankushg commented 2 years ago

Sorry I wasn’t clear: I’m definitely trying to use it in tests!

To be more specific:

What I’m looking for is being able to

SalomonBrys commented 2 years ago

That is not possible at the moment, due to this KSP issue: https://github.com/google/ksp/issues/567. This forces us to apply a workaround: generate code for jvm (with the kspJvmTest configuration) and apply the result to all source sets. This evidently breaks expect interfaces. Once this KSP issue is fixed, then we'll be able to work on expect interfaces: we'll have KSP will run on each source-set, generating a mock for each full actual interface.

SalomonBrys commented 2 years ago

I reopen this issue because the use-case is valid, and MocKMP does not support it at the moment. However, until the aforementioned KSP issue is fixed, consider it dormant, as I don't think it can be done.