Saturday, April 1, 2017 -
1:00pm to 1:45pm

Session video

Post Session Resources:

SlidesGitHub Repository, Blog Series <- I forgot to mention this, I'll be doing a series of blog posts that go into a lot more detail and should get you from zero to writing real, useful tests.


With Drupal 8's radically different architecture, the testing story has been completely overhauled. Over the past year, I've had the incredible opportunity to program for Drupal 8 and solve many interesting problems. Along the way, I've learned how to write practical and efficient tests. What I've discovered is that those tests have made it easier to work in a team, make me feel more confident about the code I write, and make my code easier to change as project requirements evolve. In short, they're more than worth their investment. In fact, they make me even more productive where it matters.

In this session, we won't presume that you've done a lot of automated testing—or any at all. We won't wring our hands over behavior-driven or test-driven development. We'll discuss the how and the why from the get-go. We'll clear as many obstacles as we can. We'll learn from my mistakes (and maybe from my successes). And by the end, hopefully you'll have the tools to start your own journey toward testing Drupal 8 simply and efficiently (read "cost-effectively").

Specifically, you'll learn how to extend Drupal's testing classes like UnitTestCase, KernelTestBase, and WebTestBase to test your custom applications from top to bottom. With those tests in place, automated testing on every git push and testing against your team's PRs will be within reach.

This presentation is an intermediate track because you'll need to be familiar with PHP and be familiar with some Drupalisms. Bonus points for some Drupal 8 knowledge, especially familiarity with Drupal's service/controller/plugin concept, however this is not required.

Like so many Drupal developers, I started my professional programming career by building Drupal sites, writing custom modules, and contributing where I could. Unfortunately, that path never exposes one to the art of testing. Before Drupal 8, testing was prohibitively difficult and costly. Outside of core and the most used contrib modules the value of testing didn't seem to outweigh the costs. Without a mentor and/or lots of time to spend learning—one would probably never get the chance to become familiar with the practice of automated testing. Or, so I thought.