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

Adam S

03/11/2023, 12:47 PM
is there a Kotlin Multiplatform equivalent for the Java Test Fixtures plugin? I want to share test helpers between subprojects, per target platform (so there would be jvmTestFixtures, jsTestFixtures, etc).
v

Vampire

03/11/2023, 1:10 PM
Not that I'm aware of, but afair the plugin mainly defines a feature variant and provides a helper method to request that variant's capability. So probably not too hard to replicate.
sharing multiplatform to multiplatform could probably be done similarly
a

Adam S

03/11/2023, 1:42 PM
thanks @ephemient, that looks promising
what’s the difference between the
jvmTestRuntimeClasspath
config and the
runtimeDependencyFiles
? Do the dependency files contain the test classes themselves?
Copy code
val parent = configurations.getByName("jvmTestRuntimeClasspath")
extendsFrom(parent)
Copy code
jvmTestFixtures(compilations.getByName("test").runtimeDependencyFiles)
e

ephemient

03/11/2023, 1:52 PM
yes, but that's probably not something you need, I'm just re-exporting the test cases so I can re-run them in another project
(which would normally be a pointless thing to do, why run the same test multiple times; it only makes sense in my example because I'm recompiling it with graalvm)
under normal circumstances you'd more likely want test to depend on testFixtures
a

Adam S

03/11/2023, 2:01 PM
gotcha, thanks
it exposes the test classes like yours did too, just to test to see if it works first
I think it’s working, at least the unit tests are passing, but IntelliJ isn’t happy. It doesn’t recognise that there’s a dependency
basically I just ignore the IDE. as long as it builds it's right
v

vladimirsitnikov

03/11/2023, 5:56 PM
Why not extracting the helpers into its own module?
a

Adam S

03/11/2023, 6:08 PM
1. I'm updating the Gradle config of an existing code base and I wanted to avoid making too many changes 2. the test-fixtures code needs to be able to access
internal
visibility code
14 Views