{# Description text for the PHPUnit Example. #} {% set sum_in_hands = path('testing_example.sum_in_hands') %} {% trans %}

Testing Frameworks in Drupal

This module provides a path so we can test it. The path takes two numeric arguments, and tells you how many hands are required to count the sum of both numbers.

How to use this example module

You really should be reading the various documentation comments in the files under tests/src/.

How To:

Type Location Namespace Subclass of
Unit test [your_module]/tests/src/Unit Drupal\Tests\[your_module]\Unit\ Drupal\Tests\UnitTestCase
Kernel test [your_module]/tests/src/Kernel Drupal\Tests\[your_module]\Kernel\ Drupal\KernelTests\KernelTestBase
Functional test [your_module]/tests/src/Functional Drupal\Tests\[your_module]\Functional\ Drupal\Tests\BrowserTestBase
FunctionalJavascript test [your_module]/tests/src/FunctionalJavascript Drupal\Tests\[your_module]\FunctionalJavascript\ Drupal\FunctionalJavascriptTests\WebDriverTestBase
Shared test traits [your_module]/tests/src/Traits Drupal\Tests\[your_module]\Traits\ n/a

Standard PHPUnit Practices

You can run PHPUnit from the command line or via the run-tests.sh command.

You can specify which type of test you're running via

phpunit --testsuite
and
run-tests.sh --types
.

There are many options to phpunit, but, for instance, to run all of the testing_example phpunit tests, you could

./vendor/phpunit/phpunit/phpunit -c core/ ./modules/examples/testing_example

{% endtrans %}