Any mocking library for kotlin native tests?
# kotlin-native
r
Any mocking library for kotlin native tests?
🚫 3
b
I stumbled across this yesterday, which appears to have some support for mpp and mocking: https://github.com/MarkusAmshove/Kluent
I have not tried it though
nvm. looks like the
mock
function is JVM only 😞
j
mockk works great. I've been creating unit tests in common module
b
Does it support native? Last I checked, the mocking parts don't work on native
j
Only common 😢
b
Common should compile for native though. Only JVM you mean?
d
Our team put together a poc wrapping existing mocking frameworks. We created and expect class in common and delegated actual implemetations to Mockito on the JVM and OCMockito on iOS. Got stubbing and verifications working but have not tested any other functionality
j
common tests run on jvm afaik
c
I always thought common tests run on each platform 🤔
you won't find mocking libraries for native until there is some kind of reflection
r
@jeremy no, you should run your common tests on every platform, because you can easily write a simple test that pass on JVM but not on iOS
d
If you run your test using the
check
task, your test will run on each targeted platform.
r
That’s simply not true
check
runs tests for platforms
JVM, Android, Linux, Windows and macOS
d
@ribesg it sounds like we are saying the same thing, . Are we saying something different?
r
No. You can target more than those platforms I listed.
d
I currently have a 51 test in commanMain(no platform dependent test). When I run the check task, it reports running 102 tests. I'm targeting Android and iOS
r
They don't run on iOS
You need to run them on IOS too
d
So it's running Android twice?
r
You probably have 2 variants, debug and release. It runs once per variant on Android
d
Hmmm...good call. I'll double check that
r
The mpp plugin does not support running iOS or JS tests
JS is coming in 1.3.40 I think
You need to create a Gradle task executing xcrun for iOS
d
Thanks for the info
a
Linux runs with check task just fine. JS and iOS require special configuration.
j
Do you have an example of setting up gradletask + xrun? xrun executes via console or on device?
a
Sure, you can find linux, iOS and JS tests configured here https://github.com/badoo/Reaktive
🎉 1
You can run them with "check" Gradle task, and they ran automatically by Travis
r
I defined a separate
checkIos
task because I prefer to see everything that runs inside IntelliJ when running
check