Unit tests in Drupal: The road to test-driven development

fmizzell
eric.napier

Test-driven development requires short development cycles in which we write tests describing our software and then write the code that will make the tests pass.

Short develoment cycles require fast tests, and unit tests are the fastest in our arsenal.

Unit tests in Drupal might seem like an impossibility, given that most of our code lives inside the world that Drupal has constructed for us (Hooks/Events, Entities, Plugins, etc).

With unit tests alone,  we have managed to maintain ~100% test coverage in our complex Drupal 8 systems, and would like to share how we accomplished this with you.

Learning Objectives

At the end of this session, attendees will:

  1. Understand different techniques to make their code more unit testable
  2. Be able to effectively implement true unit tests in Drupal
  3. Know of tools that can help them write unit tests

Target Audience

Anyone interested in unit tests.

Prerequisites

Some familiarity with phpunit, sevices, and dependency injection in Drupal 8 can be helpful. 

Track

Development & Coding

Tags

php
testing

Experience Level

Intermediate

When & Where

Time: 
Wednesday, 15 July, 2020 - 19:15 to 20:00
Room: 
Hopin Sessions

If no timezone is set on your profile, time is displayed in UTC.
Update your profile's timezone