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
Bug: Kotlin multiplatform project fails to build with mockk dependency #322
Comments
Thanks for the report |
Did you find a work around for this? |
same issue here ... any way to work around this? |
Same issue Kotlin version: 1.3.50 |
Hello. Same here. Any update on this? |
Had the same issue. For now I had to stop using mockk altogether for KMP as I don't know any workaround. Is there any update? Thanks! |
Same issue with Kotlin multiplatform-1.4.0. Except new update to fix it. |
Same Issue, someone has an update for this? Thanks! |
Any workaround available? |
I think basically mockk has no support for Kotlin Multiplatform so it is not possible to use this library with it. |
probably soon it could be supported |
Same issue here :( |
I just started playing with Kotlin Multiplatform recently so I am not too familiar with it yet, but today I tried adding MockK to one of my commonTest tests and it seems to be working. I'm using
Here is my test file under commonTest
|
One thing I noticed is the default gradle tasks executed when I select a test on my I am not sure why those are the defaults for this module, but if I instead run |
Reproduces in Kotlin 1.4.32 |
Probably found the workaround. Instead of just adding: Works like a charm for my project |
@ILikeYourHat Thank you, that worked for me too. |
Unfortunately the solution of adding |
I do not know how but after appliying this, now my files see mockk dependency and kmm project structure also not broken:
|
Same issue here. When using Mock we can run the test in commonTest but when trying to run the test in iosTest folder it fails on :compileTestKotlinIosX64 task |
there's an effective and easy workaround for this issue if your goal is to use if that's your case, here's my tip: create stub implementations of if you want to use
another tip to make your life easier is to open mockk method implementation using your IDE and just copy the signature and paste on your stubbed mockk 😄 attention that you only have to create these stubs inside iosTest source set. disclaimer: I'm not providing an elegant way or the best solution ever. For now, it's the easiest way that I found to solve my problems. 🍻 |
It looks like all of the "solutions" here are workarounds to get the tests building and running on something other than the native Apple-compatible code. That part we have working no problem. No one seems to be able to get mockk tests running natively on a Mac. |
yes, you are right about the workarounds and stuff! actually the solution I've mentioned above works on mac machines 😃 |
@leocabral but aren't you running the tests using the JVM, which is not how the code would execute on an iOS simulator or a real iOS device? I want to verify the functionality of the code when compiled for iOS itself (or least simulator), not the JVM. |
@silverhammermba yes, I am! so indeed, your need cannot be accomplished by |
Hi. Any news about this issue? I can not publish my KMP library due to this issue during JS test task. Unresolved reference: mockk |
Hi @ComBatVision , you can just change the name of your directory from
|
Almost 3 years, how soon? LOL |
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Current Behavior
I'm working on a kotlin multiplatform project, when I try to write some unit test by using MockK, I got the
Unresolved reference: xxx
error when I run the./gradlew :common:build
, don't actually know this case relates to this issue(#58 ) or not.Steps to Reproduce
You can clone the project https://github.com/littleGnAl/accounting-multiplatform/tree/littlegnal/common-test.
Uncomment the https://github.com/littleGnAl/accounting-multiplatform/blob/littlegnal/common-test/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt.
Then run the
./gradlew :common:build
to reproduceContext
My gradle configuration is like below:
The text was updated successfully, but these errors were encountered: