MocKMP
MocKMP copied to clipboard
Feature Request: Enable mocking for `expect interface`
It would be nice to be able to mock an expect interface with generated mocks for the actual interface for each target 😄
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.
Sorry I wasn’t clear: I’m definitely trying to use it in tests!
To be more specific:
- I’ve got an expect interface in commonMain,
- already have actual interfaces in JVM and iOS
- My commonMain code extensively uses the expect interface
What I’m looking for is being able to
- write a test case in commonTest that only verifies behavior of methods on the common expect interface
- tell mockmp to mock the expect interface in commonTest, and
- have mockmp generate mocks via the (already existing!) actual interfaces for each target
- Have mockmp allow me to mock the common methods in commonTest
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.
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.