BDD and Behat. What, why, and how?

BDD and Behat. What, why, and how?

Speaker(s)
valthebald
Duration
Session track
Devops
Experience level
Beginner
Description
What

is BDD. Behat and its competitors

Why

BDD is relevant, but not used as widely as it should

How

is it all related to AI

This session should cover the following topics
  1. Introduction to Behat: Overview of Behat, its role in BDD, and how it differs from PHPUnit
  2. Setting up the development environment with ddev
  3. Writing acceptance tests, features and feature contexts. Step definitions
  4. Drupal-specific extensions (e.g., DrupalExtension)
  5. Test suites.
  6. Integrating into a CI/CD pipeline: Configuring Gitlab CI, Travis CI, CircleCI, or Jenkins
  7. Using real browsers with Selenium WebDriver or ChromeDriver
  8. Generating test reports and visualizing results
  9. Using AI helpers to maintain the test base.

Switching to Behavior-Driven Development mindset has helped numerous projects I was involved, so why isn't this approach used always?

In theory, everybody agrees that automated tests is a good thing. In practice, when the deadlines approach, and "must-have" features take longer than expected, the easiest solution to deliver a project time is to cut the corner and postpone writing the automated tests for the future (which almost never happens).

To make things worse, no matter what technology stack you use, there are 2 steps that need to happen before writing tests starts to make any sense:

  • You need a setup that will run the tests continuously (otherwise tests result become irrelevant after some time)
  • You need to write your first test

Behat (an open source BDD ramework for PHP) used to be the go to tool for functional/integration tests for the client projects. Almost natural language (Gherkin), good integration with Drupal and drush, and decent documentation, it was doing its job.

What happened then? I guess the same that happened to PHP itself - newer and "fancier" (or agressively promoted?) tools that took the developers' hearts by storm.

The game changer that hopefully may improve the situation is the word you hear from every corner this year - AI.

Session slides are available here