In this 4 hour workshop you will learn how to write your own automated tests in Drupal.
Drupal has a long history of using automated tests to guarantee its stability and prevent regressions. Every new feature or bug fix that is added to Drupal core requires a test to prove that it works as intended. This practice is also adopted by most popular contributed modules.
Apart from the testing systems supported by Drupal core, the third party testing framework Behat has also been making a big impression, it's Behaviour Driven Development (BDD) principles making it a great choice for testing client projects with high functional testing efficiency for a low time investment.
In the first part of the workshop you will learn the basic theory of testing, and slalom around all the testing frameworks included in Drupal core:
- Different types of manual and automated testing
- History of automated testing in Drupal
- The rise and fall of the Simpletest module
- Running PHPUnit tests
- Location and namespaces to use for your tests
- Writing integration tests using BrowserTestBase
- Writing fast functional tests using KernelTestBase
- Writing unit tests with UnitTestCase
- Using Prophecy for mocking dependencies
- Using data providers
- Doing code coverage tests in PHPStorm
- How to debug tests
In the second part you will learn to use Behat for testing end user behaviour:
- How Behat ties in with an agile workflow
- The Gherkin language
- Configuring Behat in Drupal
- Running tests from the console
- Using built-in step definitions
- Writing custom step definitions
- Using Selenium to run tests in a real browser