AndroidDev-social / DodoForMastodon

🐘 Mastodon client for Android, iOS and Desktop (JVM)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEAT]: Mocking?

bitPogo opened this issue · comments

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.

commented

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.

Mockk only works on jvm/android...so no KMP/you can only run tests on those platforms.
Besides, I think we need to clarify the terminology first (I definitely spend too much time on that topic) - I go by the definitions of M. Fowler. I am not sure what you mean by fakes, since these are in my experience the most expensive one.

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 runs). Also, KMock can provide spies* which the others do not have so far I am aware of.

And I totally agree, this repo can be source of documentation as real life product.

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.