Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Enable mocking for expect interface #18

Open
ankushg opened this issue May 9, 2022 · 4 comments
Open

Feature Request: Enable mocking for expect interface #18

ankushg opened this issue May 9, 2022 · 4 comments

Comments

@ankushg
Copy link
Contributor

ankushg commented May 9, 2022

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

@SalomonBrys
Copy link
Member

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
Copy link
Contributor Author

ankushg commented May 12, 2022

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

@SalomonBrys
Copy link
Member

That is not possible at the moment, due to this KSP issue: google/ksp#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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants