Change record status: 
Project: 
Introduced in branch: 
9.2.x
Introduced in version: 
9.2.0
Description: 

The global function dump() allows variable information to be added to the testing output.

This works with Unit, Kernel, and Browser tests. For instance:

class SomeTestClass extends Unit|Kernel|BrowserTestBase {

  public function myGreatNewTest() {
    $role = Role::create(['id' => 'test_role']);
    dump($role);
  }

}

In Unit and Kernel tests, the information will be output on the command line.

In Browser tests, dump() in the test code will cause output on the command line; dump() in SUT code, that is, in the site code that is being tested will cause output in the HTML page.

The global function dump() is provided by Symfony's VarDumper component. For more information see https://symfony.com/doc/current/components/var_dumper.html.

The global function debug() has been deprecated and will be removed before Drupal 10.

Impacts: 
Module developers
Themers
Site templates, recipes and distribution developers