I am building an SDK using kotlin multiplatform fo...
# multiplatform
v
I am building an SDK using kotlin multiplatform for iOS and Android. Most if not all of my code is in commonMain. Can someone please suggest a mocking library? I plan to test in commonTest. I understand some people test in androidTest to use JUnit and Mockito. I don't think that is advisable. I read MocKMP doesn't support commonTest.
j
I advise not mock at all if you can, use Fakes instead. Or what features do you need mock for?
v
Can I ask why would you advise against mocking? I am trying to mock all dependencies of a class. Same as I have always done on other platforms.
j
Its a long story, but many companies I worked on and in more vanilla Kotlin best practices the recommendation is going for fakes rather than mocks. Its a lot of details why, but wont list all of them now. Instead of mock dependecies, create fakes for them to emulate what need 🙂 And if any class depend on SDK specific stuff make sure can fake that class so reducing that need.
m
I use mockative in my project
j
Here is the longer story: https://tyrrrz.me/blog/fakes-over-mocks
v
@Mustafa Ozhan Have you been able to use it for testing common code using both android and ios as target?
m
Yeap I do, the project is public so you can check here: https://github.com/Oztechan/CCC If you interest only in android&ios you can check the modules in
client
. In
common
i also target to
jvm
for backend. ie the modules in
:client:viewmodel:x
are all has tests for ios & android