Is there a way to share test code between modules?...
# multiplatform
a
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
commonTest?
oh, between modules, got it
a
Yep
k
a shared library is what pops into my head
a
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
I use the main sources of a shared module to do this in Multiplatform Settings.
k
sounds like you have an example? 🙂
a
I think just a regular module with the test code inside commonMain source set.
r
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
🙌 1
n
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()