Change record status: 
Project: 
Introduced in branch: 
8.3.x
Introduced in version: 
8.3.0
Description: 

This change fixes two issues with test discoverability:

  • Simpletest UI, PHPUnit's test runner and run-tests.sh were discovering tests in a slightly different way
  • No "documented" way of using Traits for PHPUnit-based tests

Before

Simpletest UI

  • Discover tests in tests/src/Unit, tests/src/Kernel, tests/src/Functional, tests/src/FunctionalJavascript only
  • No way to share trait between test suites

PHPUnit's test runner and run-tests.sh

  • Discover all tests within tests/src
  • Possible to share trait between test suites
  • Loads other (not known to core) tests

After

Simpletest UI, PHPUnit's test runner and run-tests.sh

  • Discover mechanism is the same
  • Only Unit, Kernel, Functional, FunctionalJavascript tests will be discovered by phpunit. Only these and Simpletest-based tests will be discovered by run-tests.sh. This means that a test must be in one of the suite subdirectories to be discovered. For instance, a test in tests/src/ will not be discovered.
  • Traits will only be discovered in tests/src/Traits.
  • No other tests, traits, or interfaces will be loaded

See the updated documentation here: https://www.drupal.org/docs/8/phpunit/phpunit-file-structure-namespace-and-required-metadata

Impacts: 
Module developers