Is testing supported in K/N platform modules in a ...
# kotlin-native
s
Is testing supported in K/N platform modules in a Multiplatform configuration?
o
It shall be, using standard Kotlin testing APIs. Do you have any issues?
s
I guess my configuration is somehow wrong then
Do you have any pointer with a working multiplatform testing configuration?
i
Yes, tests are supported for mutliplatform projects. Although there is no special DSL for them yet you may build a test executable manually by adding
extraOpts '-tr'
in a program block. You can also find some example of multiplatform testing here: https://github.com/JetBrains/KotlinMultiplatformPlayground.
👍 2
s
thank you very much @ilya.matveev
but why is
commonSourceSets
needed ? Shouldn’t it be inferred since its a MPP project?
i
By default the
main
source set is used and this should be enough for usual use cases (the most noticeable exception is common tests).
commonSourceSets
is just an option allowing one to use a custom source set with common sources.
👍 1
s
Alright! I actually would have expected to declare
commonSourceSets 'test'
(instead of
commonSourceSets 'main', 'test')
since
main
is included by default
i
Originally this option is intended rather for overriding source set than for adding new ones. Using it for building a test binary is kind of a workaround and we will provide a more convenient DSL for test declaration.
👍 1
s
Awesome, thank you!