By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0-beta11
Description:
As part of the modernization strategy of the test infrastructure #2304461: KernelTestBaseTNG™ changes KernelTestBase to leverage phpunit instead of simpletest as testing base.
This has several advantages, pretty much the same ones like phpunit has, like better tool support.
In order to change your kernel test to use the new infrastructure you need to take the following steps:
Conversion
Note: Until Drupal 8.0.x just straight conversions are allowed to land in core itself. What are straight conversions. Straight conversions are conversions
that just change the base class
- Extend from
\Drupal\KernelTests\KernelTestBaseinstead of\Drupal\simpletest\KernelTestBase - Use a new place for the tests:
rename from core/modules/system/src/Tests/Extension/ModuleHandlerTest.php rename to core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.phpAnd update the namespace accordingly:
-namespace Drupal\system\Tests\Extension; +namespace Drupal\Tests\system\Kernel\Extension; - (optional) Move the assertions from simpletest to phpunit ones, see
RandomGeneratorTraitas a mapping - Use
settingsSet()tosetSettings() - Use
register()instead ofcontainerBuild
Run the kernel tests using phpunit
$ cd core
$ export SIMPLETEST_DB=mysql://root:@localhost/dev_d8; ./vendor/bin/phpunit --testsuite=kernel
Impacts:
Module developers