How can i access the commonTest or androidUnitTest...
# gradle
v
How can i access the commonTest or androidUnitTest sourceSet of another module when depending on it? Example, If Module A depends on Module B via
implementation
, i can access the commonMain sourceset correctly but how can i access Module B's
commonTest
sourceset in Module A's
commonTest
? Is this possible?
j
You can’t, and test fixtures do not work with Kotlin Multiplatform yet
v
So, If i want this kind of behaviour, mainly for fakes How should i approach it? Every module having another
:moduleX-fake
module to keep the fakes in commonMain?
j
Exactly that
v
That would increase module count, 1 extra module for each module I was trying to avoid this, any other way?
🚫 1
v
@Javier why shouldn't it be possible like in any other normal project? KMP shouldn't be that special. https://docs.gradle.org/current/userguide/cross_project_publications.html should apply there as well, so you can for example just have an outgoing configuration you request explicitly, or register a feature variant from that source set.
It's just not set up for that by default, as the
test
source set is meant to test the production sources of the same module, not provide test fixtures to other modules.
For that the test fixtures are meant. And even if they are not yet compatible with KMP, you can surely model something similar manually.
j
@Vampire there is an open issue about this on YouTrack as it was not working some time ago. I doubt it is working nowadays.
v
I did not say test fixtures are working now. As far as I know they are still not compatible with KMP. But that does not mean that you cannot use the same principle.
👍 1
1
v
If i want text fixtures to work only for androidUnitTest sourceSet and not commonTest Would it work?
v
Again, test fixtures as they are right now you cannot use at all with KMP. But you should be able to use the same principle to get it to work. I also linked you to the documentation of the two ways how to properly share stuff from one project to the other.
v
Thanks, i'll check the documentation
👌 1
e
that amounts to making your own implementation of test fixtures for KMP
that'll be doable for some targets (JVM can just copy what the built-in plugin does) but for others… it's just not going to be possible for the Android target inside or outside of KMP
c
But that does not mean that you cannot use the same principle.
The Kotlin plugin hides a lot of the machinery that you would need to be able to do this.