https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Arkadii Ivanov

01/16/2020, 11:13 PM
Is there a way to share test code between modules? I want test code of module "A" to use test code from module "B". Tried
java-test-fixtures
plugin but it does not seem to work in MPP environment.
k

Kris Wong

01/16/2020, 11:16 PM
commonTest?
oh, between modules, got it
a

Arkadii Ivanov

01/16/2020, 11:17 PM
Yep
k

Kris Wong

01/16/2020, 11:17 PM
a shared library is what pops into my head
a

Arkadii Ivanov

01/16/2020, 11:20 PM
It works but then code is considered as production, e.g. there are warnings about underscores in test names etc. Also you can't run tests from a non-test source set. Not a big dial for me but still. Maybe there is way to share commonTest somehow.
r

russhwolf

01/17/2020, 12:34 AM
I use the main sources of a shared module to do this in Multiplatform Settings.
k

Kris Wong

01/17/2020, 1:57 PM
sounds like you have an example? 🙂
a

Arkadii Ivanov

01/17/2020, 3:10 PM
I think just a regular module with the test code inside commonMain source set.
r

russhwolf

01/17/2020, 3:14 PM
Oops sorry that wasn't a very useful comment, was it? I have this module
tests
(https://github.com/russhwolf/multiplatform-settings/tree/master/tests) which has shared test code including a base class with shared test definitions. It gets consumed by test sources of other modules, eg here https://github.com/russhwolf/multiplatform-settings/blob/master/multiplatform-settings/build.gradle.kts#L39
n

Nick

04/23/2020, 4:13 AM
I'm looking for the same thing. I also can't have a shared, production module for this b/c my test fixture needs internal access for the module it will provide utilities for. This seems to be the exact use case for test-fixtures. But i'm having issues when trying to consume one using
Copy code
testImplementation(testFixtures(project(':foo')))
I get the following error:
Copy code
Could not find method testFixtures()
3 Views