I was looking a way to create shared test dependencies under test folder in a Kotlin - Gradle - Spring Boot multi module project.
For example:
-parent-module
-child_1_module
- scr
- main
- test
- build.gradle.kts
-child_1_module
- scr
- main
- test
- build.gradle.kts
-child_shared_module
- scr
- main
- test
- com.domain.testUtilities
- TestUtil.kt
- build.gradle.kts
This is my structure and I want to use classes from test utilites in chlid 1 and 2 tests. I came upon Gradle's testFixtures
but I do not think it works with Kotlin - or I missed something in the config. My implementation for testFixtures was:
java-library and java-test-fixtures
to sharred moduletestImplementation(testFixtures(project(":child_shared_module")))
Those are the basic instructions I found in Gradles documentation. But still I do not see the the TestUtil in child 1 and 2 tests.
I am using Gradle v8.5 and Kotlin 1.9.22
Try to change folder name from test
to testFixture
-child_shared_module
- scr
- main
- testFixture
- kotlin
- com.domain.testUtilities
- TestUtil.kt
It is written so in documentation
Perhaps you intentionally omitted the need for a kotlin
folder, but I’ll include it in my example to provide a more complete solution.