The term extension will be used to refer to themes and modules interchangeably.
Drupal\Tests\{extension_name}\{suite type}
\AKlump\DrupalTest\*\UnitTestCase
for your Unit test classes.Each module or theme provides tests and schema files relative to it's own directory (.
). Following this convention allows the test runner to auto-discover these tests. e.g.,
.
└── tests
├── jsonschema
│ └── story_resource.json
└── src
├── Client
│ ├── Service
│ │ └── EarthriseServiceClientTest.php
├── Kernel
│ ├── Service
│ │ ├── BreakpointServiceKernelTest.php
│ └── TransformKernelTest.php
├── TestBase.php
└── Unit
├── Service
│ └── EarthriseServiceUnitTest.php
└── TransformUnitTest.php
Unit and Kernel tests do not have to test a single class, for example if you are writing a test to cover theme functions. In order to make this happen you have to do the following in your test class:
class InTheLoftThemeKernelTest extends KernelTestCase {
protected $schema = [
// By setting this to false, we indicate we are not testing a class.
'classToBeTested' => FALSE,
];
...