-
Book Overview & Buying
-
Table Of Contents
Drupal 9 Module Development - Third Edition
By :
There are certain commonalities between the various test suite types regarding what we need to do in order for Drupal (and PHPUnit) to be able to discover and run them.
First, we have the directory where the test classes should go. The pattern is this: tests/src/[suite_type], where [suite_type] is the name of the test suite type this test should be. It can be one of the following:
So, for example, unit tests would go inside the tests/src/Unit folder of our module.
Second, the test classes need to respect a namespace structure as well:
namespace Drupal\Tests\[module_name]\[suite_type]
This is also pretty straightforward to understand.
Third, there is a certain metadata that we need to have in the test class PHPDoc. Every class must have a summary line describing what the test class is for. Only classes that use the @coversDefaultClass attribute can omit the summary line...