Join Slack
Powered by
Hey guys, any advice on mocking in commonTest? I t...
# multiplatform
t
tjohnn
11/27/2020, 8:07 AM
Hey guys, any advice on mocking in commonTest? I tried mockk without success
k
KamilH
11/27/2020, 8:18 AM
As far as I know there are no multiplatform solutions yet. Mockk is working on support for iOS and JS, but it’s not ready yet. When writing multiplatform apps interfaces and fake are your best friends in tests 🙂 You will write a little bit more code than with mockk, but I think it is a good practice to prefer fakes vs mocks Here is the interesting article about it:
https://medium.com/@june.pravin/mocking-is-not-practical-use-fakes-e30cc6eaaf4e
Here you can see my approach:
https://github.com/audioburst-labs/AudioburstMobileLibrary/blob/master/src/commonTest/kotlin/com/audioburst/library/interactors/Mocks.kt
KamilH
11/27/2020, 8:22 AM
I would also recommend plugin `Kotlin Fill Class`:
https://plugins.jetbrains.com/plugin/10942-kotlin-fill-class
for faster class constructor filling with default values and multiline (option+CMD+shift+left click) editing
a
Arkadii Ivanov
11/27/2020, 11:47 AM
You can't mock in common tests. I recommend the following article:
https://medium.com/@june.pravin/mocking-is-not-practical-use-fakes-e30cc6eaaf4e
2
Views
Open in Slack
Previous
Next