gradle-plugins/toolbox

Allow configuration of the `runtimeOnly` dependencies for each test variant

Closed this issue · 1 comments

Allowing this feature will open the possibility to use a different gradleApi hence running unit tests against different Gradle versions. It is useful to run some tests quickly against a range of Gradle versions.

Despite the initial intent to provide runtimeOnly dependencies for each test variant, we don't model variants (yet). It would require a bit of restructure. How this issue would be solve also overlap with Nokee's testing plugins. For now, we wrote the required APIs to achieve the same purpose with minimal configuration. Where is a sample:

            test {
                testingStrategies = [strategies.${coverage}]
                testTasks.configureEach {
                    classpath = files(testingStrategy.map {
                        project.getConfigurations().detachedConfiguration(dependencies.gradleApi(it.version))
                    }.orElse([])) + classpath
                }
            }

Note that we prepend the detached configuration to the classpath as there are some mechanics that already adds the Gradle API to the unit test classpath. This sample should be enough to solve this issue.