An effective testing strategy demands many tools in our tool belts. Let’s take a look at some tests, environments, and tools for Test-Driven Development (TDD):

  • Behavior-Driven Development (BDD) ensures the application functions as we are intending, and serves as documentation. We’ll look at leveraging existing Behat definitions and explore opportunities to compose our own.

  • Visual regression testing is great for ensuring your site keeps looking the way it is supposed to when changes are introduced.

  • Unit testing is fast, cheap, and perfect for testing granular functions. We can also extend Drupal classes to test the Kernel, Browser, and JavaScript bases.

There was a question about running Drush commands in Behat. It looks like that would be done with the following syntax:

Given I run drush "command" "arguments"

There was a question about Drupal PHPUnit Base class inheritance. Here are the extensions of the base classes covered:

  • UnitTestCase extends TestBase
  • KernelTestBase extends TestBase
  • BrowserTestBase extendsTestBase
  • JavaScriptTestBase extends BrowserTestBase
Note that TestBase extends \PHPUnit_Framework_TestCase