By berdir on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
Additionally to following the PSR-4 namespace rules, automated test classes need to be defined inside the Tests namespace of a module, e.g. Drupal\tracker\Tests.
The common base test classes provided by Simpletest have been renamed, DrupalWebTestCase to Drupal\simpletest\WebTestBase and DrupalUnitTestCase to Drupal\simpletest\UnitTestBase.
The following test class specific additions/exceptions to the general class naming rules have been defined:
- Test classes should always have the suffix "Test".
- Test classes should use the "TestBase" suffix, if they are only used as base helper class for other tests and do not contain own test methods.
- Test classes only need to be unambiguous within the context of the module they are testing.
See Object-oriented code for details and examples.
Example
Drupal 7
modules/tracker/tracker.test
class TrackerTest extends DrupalWebTestCase {}
Drupal 8
core/modules/tracker/src/Tests/TrackerTest.php
namespace Drupal\tracker\Tests;
use Drupal\simpletest\WebTestBase;
class TrackerTest extends WebTestBase {}
TBD: Naming scheme of tests for Drupal\Core and Drupal\Component namespaces.
Impacts:
Module developers