Replies: 6 comments 14 replies
-
Awesome topic - might be better have thrown this under General Discussion first to reduce some noise/discussions, but all good! Lets see what others think and then we bring this in I am most familiar with https://mockk.io/ but don't know if there are any implications with use in a KMP project. We should also write up some documentation/best practices in this repo with guidelines on when to use fakes vs mocks. It's a discussion that happens often in the community and this repo could serve as a great source of documentation and knowledge for best practices etc. |
Beta Was this translation helpful? Give feedback.
-
Mockk only works on jvm/android...so no KMP/you can only run tests on those platforms. MocKMP feels closest to mockk at first. But (cautious I am opinionated) has its issues might still break from case to case (but it got better). MocKMP is like mockk intrusive and provides only mocks. Mockative is semi intrusive, but super opinionated about its usage. KMock is also semi intrusive, since it produces Stubs, but you can also use it like mocks (with And I totally agree, this repo can be source of documentation as real life product. |
Beta Was this translation helpful? Give feedback.
-
Not really a fan of mocking libs personally. I should really write a blog post about it, but https://www.billjings.com/posts/title/fakes-are-great-but-mocks-i-hate/ covers some problems pretty well. |
Beta Was this translation helpful? Give feedback.
-
I think fakes would be the best option for KMP |
Beta Was this translation helpful? Give feedback.
-
We use KMock (in places where we auto-gen mocks, which isn't everywhere). We did a relatively extensive internal review of a few libraries and wound up using KMock. It was 7/8 months ago, though. Anyway, just my 2 cents. The other KMP options we tried out didn't have anything significantly different that was missing in KMock. |
Beta Was this translation helpful? Give feedback.
-
⛔️ This discussion is closed. Please vote or check for results |
Beta Was this translation helpful? Give feedback.
-
Description
Since this will be at some point a topic in terms of testing and has some implications - are we going for mocks?
Currently, there 3 Frameworks (I know of):
Mockative -> not sure if this is still active
MocKMP
KMock -> my baby/you can play with it here
Additional Information
A few words to KMock - I am currently preparing my next iteration of, which will bring, aside from some dependencies updates, some new stuff. But I will need a bit time for that.
However, KMock is a bit different to mockk or Mockito if you are used to it, so I recommend trying it upfront. The big plus is no worries about the setup since the KMock's gradle plugin will do it. It is tightly tested so most limitation are known this far.
Beta Was this translation helpful? Give feedback.
All reactions