Module Development

Implement a Functional Test for Drupal 8, 9, and 10

In this tutorial, we'll walk through the basics of how to implement a functional test by extending Drupal's BrowserTestBase class. We'll assume you've already determined that you need to write a functional test and that you've Set up a Functional Test.

In this tutorial, we'll:

  • Determine the specifications of the test.
  • Walk through the behavior we want to test.
  • Document our test in the test class.
  • Implement the testing steps.
  • Decide how to deal with dependencies (for now). (We'll go into details about handling test dependencies in Implement Drupal Functional Test Dependencies.)