Overview
We should consider replacing our custom TestSourcesPlugin with Gradle's official support for Test Fixtures.
Rationale
- Currently all test code is visible in all other (downstream) projects, and that makes it too easy to introduce unnecessary coupling.
- For example, this made it more difficult to migrate to JUnit Jupiter.
- Having test fixture code in a dedicated source folder makes it readily apparent that the code is reused across the test suite.
- It will be much cleaner if projects explicitly declare that they rely on specific test fixtures of upstream projects.
Related Issues
-
23282
Comment From: marcphilipp
It will also make builds faster because test classes in downstream projects won't have to be recompiled and tests won't have to be executed if only a test class changes in an upstream project.
Comment From: sbrannen
Update: the work on this is essentially complete and can be viewed in the following feature branch.
https://github.com/sbrannen/spring-framework/commits/issues/gh-23550-test-fixtures
The only open issue is disabling the publication of *-test-fixtures artifacts. There is a built-in feature for that in Gradle 6.x, but we'll have to find a custom workaround for Gradle 5.6.x.