Guide

Test Custom Code for Drupal 8, 9, and 10

What will you learn

  • About unit tests, kernel tests, and functional tests
  • How to write and run tests with PHPUnit
  • Setting up a development environment for testing
  • Interpreting and debugging test results

Overview

Automated testing helps ensure code quality, catch bugs early, and maintain reliability across updates and deployments, leading to more stable and maintainable projects. Learn about the different ways to run Drupal’s automated tests, the differences between them, and how to debug failing tests during development. Automated tests are an essential part of ensuring the code we write is reliable, that future updates don’t cause regressions, and that our applications remain stable.

Primary Author, Paul Mitchum
Paul Mitchum (Mile23 on drupal.org) has done work on Drupal's continuous integration project, is an active core contributor, and is one of the maintainers of the Examples project among his other roles.

Courses

Overview: Testing in Drupal

This course covers the importance of testing, the different types of tests available in Drupal, and how to organize and run these tests using tools like PHPUnit. Additionally, learners will gain practical knowledge on installing necessary development dependencies, structuring test files, and understanding the various testing frameworks provided by Drupal core.

Run tests

This course covers the use of both the run-tests.sh script included with Drupal core and the PHPUnit binary for running tests, detailing the setup and configuration required for each method. Learners will gain practical skills in running unit, kernel, functional, and functional JavaScript tests, understanding the differences and use cases for each type.

Write tests

This course covers the creation and configuration of PHPUnit for testing, how to implement unit, kernel, and functional tests, and writing tests that run in a simulated browser.. Additionally, learners will explore JavaScript testing using tools like Nightwatch.js, and understand how to manage test dependencies effectively.

“Drupalize.Me has trained thousands of Drupalistas. Their video lessons help to address our constant need for more Drupal talent. Drupal needs training like this to support its growth.”
Dries Buytaert
Drupal Founder and Project Lead
Photo of Dries Buytaert
“They’re easy to understand. They’re thorough. They’re funny. They’re always entertaining, and it makes it easy to learn parts of Drupal and how you can integrate it into your workflow and learn more and have a good time doing it.”
Roger Carr
Drupalize.Me Member
Photo of Roger Carr
“The mission of the Drupal Association is to foster and support the Drupal software project, the community, and its growth. Drupal education, like that provided by Drupalize.Me, is important to this mission.”
Megan Sanicki
Former Exec. Director, Drupal Assoc.
Photo of Megan Sanicki

FAQs

Am I required to sign a contract?
No. You can purchase a membership and/or cancel any time. Drupalize.Me is a pay-as-you-go service.

Can I preview tutorials before joining?
Yes! Just navigate to our tutorial library. Our free tutorials are labeled with a green "FREE" tag.

Can I watch videos on my mobile device?
Yes! Drupalize.Me is a responsive site and can be accessed in the browser on any mobile device. More FAQs