Problem/Motivation
In #1411074: Allow kernel tests to share the test environment we introduced the #[ShareEnvironment] attribute and in #3623409: Add the "ShareEnvironment" attribute to all Kernel tests we ensured it was consistently applied. However any new Kernel will not leverage the performance improvements offered by the "shared environment" mode by default, since we kept the old behavior when the attribute is missing to preserve BC.
Proposed resolution
Flip the default behavior when the attribute is missing, but only in the next core major version's development branch. The goal is to ensure that any project enabling testing on the next major version will automatically either work or fail in a meaningful way. To achieve this, detect a missing attribute and, in case of testing failure, output a warning with a link to the change record we will introduce here.
Remaining tasks
- Validate the proposed solution
- Post a MR
- Reviews
API changes
A Kernel test with no #[ShareEnvironment] attribute shares the test environment among the test methods.
Release notes snippet
A Kernel test with no #[ShareEnvironment] attribute shares the test environment among the test methods.
Comments
Comment #2
plachComment #3
plachComment #4
catchTagging for release manager review. Obviously I'm a release manager but I'd like a +1 from another release manager since this is slightly unique.
The idea here is that since many tests will not need to set the attribute at all, we can save a lot of busywork for contrib by making a behaviour change in a major with a CR/release note but without a deprecation. Then the tests that will 'just work' will continue to just work, and the ones that break will break only on the major branch with an error message pointing out that the attribute isn't set and that might be the cause of the test failure.