migrate test utils to use Test Fixtures plugin
Migrate test-util project to use Test Fixtures, to improve project organisation and structure.
This is a speculative PR that I have made because I think it a demonstration is more clear than trying to write it up in an issue. It introduces some breaking changes for 3rd party consumers, which might be undesirable.
Part of #2703
Summary
This PR migrates the existing test-utility projects to instead be contained inside the project in an independent source set, thanks to the Java Test Fixtures plugin.
- code and dependencies for the test-util subprojects (
:core:test-api,:core:content-matcher-test-utils,:plugins:base:base-test-utils) have been merged into their 'parent' subprojects - Local and remote projects do not need to apply the Test Fixtures plugin, and can depend on the test util code using the
testFixtures()helper function embedded into Gradle.
Breaking changes
There are two breaking changes
Updated dependency coordinates for the test fixtures.
Currently the test utility projects are published as Maven artifacts (e.g. dokka-base-test-utils). These artifacts will no longer exist. Instead, the artifacts that contain the test fixtures (e.g. dokka-base) will have two variants published, which can be depended on as follows:
dependencies {
testImplementation("org.jetbrains.dokka:dokka-base-test-utils:1.8.10") // old
testImplementation(testFixtures("org.jetbrains.dokka:dokka-base:1.8.10")) // new
}
There are two potential workarounds to make this change a little less grating:
-
Keep the
:plugins:base:base-test-utilsprojects (and others), which would expose the test fixtures as an API dependency, but would not contain any source code// plugins/base/base-test-utils/build.gradle.kts dependencies { api(testFixtures(projects.plugins.base)) }
- [ ] TODO verify that Maven coordinates for test fixtures are able to be used, and have separate coordinates
Binary Compatibility Validator support
BCV does not currently support the Java Test Fixtures plugin https://github.com/Kotlin/binary-compatibility-validator/issues/117
I've created a fork of BCV that does support them https://github.com/adamko-dev/kotlin-binary-compatibility-validator-mu
Hey, @adam-enko, is it possible to finish this PR? (or reopen new one, as there were a lot of changes in the meanwhile)
- https://github.com/Kotlin/binary-compatibility-validator/issues/117 - fixed
keep the :plugins:base:base-test-utils projects (and others), which would expose the test fixtures as an API dependency- this looks fine, but better to test it
I think it's probably best to just close this PR. It's not entirely necessary to use test-fixtures, and if they would help, then it would make sense to start again from scratch with the latest changes from master.