Change record status: 
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\KernelTestBase instead 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.php
    

    And 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 RandomGeneratorTrait as a mapping
  • Use settingsSet() to setSettings()
  • Use register() instead of containerBuild

Run the kernel tests using phpunit

$ cd core
$ export SIMPLETEST_DB=mysql://root:@localhost/dev_d8; ./vendor/bin/phpunit --testsuite=kernel
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done