Problem/Motivation

Currently Drupal test discovery system is looking for Unit/Kernel/Functional/FunctionalJavascript subdirectories within MODULENAME/tests/src directory. There are no possibility for a module to create a base test class/trait and share it between Functional and FunctionalJavascript tests for example.
See \Drupal\simpletest\TestDiscovery:

// Add PHPUnit test namespaces.
$this->testNamespaces["Drupal\\Tests\\$name\\Unit\\"][] = "$base_path/tests/src/Unit";
$this->testNamespaces["Drupal\\Tests\\$name\\Kernel\\"][] = "$base_path/tests/src/Kernel";
$this->testNamespaces["Drupal\\Tests\\$name\\Functional\\"][] = "$base_path/tests/src/Functional";
$this->testNamespaces["Drupal\\Tests\\$name\\FunctionalJavascript\\"][] = "$base_path/tests/src/FunctionalJavascript";

On the other hand, Simpletest allows for any testing configuration within the module:

// Add Simpletest test namespace.
$this->testNamespaces["Drupal\\$name\\Tests\\"][] = "$base_path/src/Tests";

Proposed resolution

Allow adding any configuration of PHPUnit-based tests within modules, but advice to use aforementioned structure.

Remaining tasks

Provide a patch.

User interface changes

None

API changes

None

Data model changes

None

Comments

Taran2L created an issue. See original summary.

taran2l’s picture

Can we do simple patch like this?

taran2l’s picture

Status: Active » Needs review