Get better at testing using Drupal Test Traits!

Topic Tracks Development & Performance Audience Intermediate

Drupal Test Traits is one of my favorite contrib projects for Drupal. DTT is a project that lets us build tests that run against an actual site installation with site data in it. Behat used to be the tool for behavior tests, but we pushed it well beyond its intended use case. With Drupal Test Traits, you can write phpunit tests that execute against your development instance to test features. They are much, much easier than writing unit tests or kernel tests, and functional JS tests set up a new instance every run. When I am doing client work, I don’t have time for all of that!

As developers, we need to show our work. When we submit a merge request for a feature on a project, we should be proving to the reviewer that our work… works!

Do you want to stop waking up in the middle of the night in a cold sweat because you’re so afraid that QA will ping you AGAIN on the custom route that you are positive has worked every single time you’ve deployed it, but it is so complex that, yeah, sometimes regressions happen?

Have you ever gotten to the end of a deliverable only to get a bug for a feature that you implemented seven months ago and really don’t 100% remember how it works? Tests can be documentation. Behavior tests, like the ones we can write with DTT, show you how to navigate your features and what results you expect. You can hand off a feature to another developer and they can see right away how something is supposed to work. It’s like a testing script you can follow through a behavior.

You can have a robot build this for you, but if you are in bed, staring at the ceiling, wondering if you’ll get a ticket on something you’re sick of looking at, tests that you didn’t actually write won’t put that worry to sleep.

What will we learn in this session?

  • We will learn how to write tests with DTT with exciting live demos!
  • Learn the right testing approach for you, and why I think it’s probably this one.
  • Let’s learn what tests should look like, what to test, and what not to test!
  • See how to integrate this into your GH CI/CD pipeline and validate every pull request!
  • We’ll go over how my teams do user stories and how to build tests that validate those requirements before we hand them to testers.
  • I’ll also show some cool little treasures and tools that I’ve build to make my tests extra awesome.

Solidify your work. Prevent regressions. Develop faster. Be more reliable. Get more sleep. Learn how to write behavior tests with me!

This session is for developers with some Drupal knowledge. Suitable for beginners to testing or experienced testers wondering how to do tests in a Drupal project.