https://kotlinlang.org logo
t

thana

07/04/2019, 7:26 AM
can my e.g.
jsTest
depend on the
commonTest
set of a different module? i'd like to provide some common test files for several modules...
a

Alexey Belkov [JB]

07/04/2019, 9:02 AM
Haven't tried it, but I believe the answer is no, for the same reason as https://kotlinlang.slack.com/archives/C19FD9681/p1559290001004200
t

thana

07/04/2019, 10:40 AM
Well no. i don;t want to add any transitive dependencies. also "it doesn't" make much sense" is not a good reason to forbid it
r

russhwolf

07/04/2019, 4:09 PM
It’s possible to share test code between modules by created a separate
sharedTests
module that defines your tests in
commonMain
, and then depending on
:sharedTests
from the test code of other modules. There’s some rough edges though. For example if you try this in JS on 1.3.40 you’ll very likely run into https://youtrack.jetbrains.com/issue/KT-31917
I had a configuration like that in Multiplatform Settings, but removed it in the 1.3.40 update due to that and another similar issue on native. Currently I share test code via
kotlin.srcDirs()
but the IDE complains when files are duplicated across multiple sourceSets/modules in that way.
t

thana

07/05/2019, 4:37 AM
Thank you! I wonder why sharing code in tests is so hard...
2 Views