In this session we will examine best practices from the Behavior-Driven Development community and apply these principles to automated testing in Drupal. This session will focus primarily on how to structure and organize tests in a BDD-friendly way regardless of the tool, and how these strategies align with a broader Agile methodology. Behat is currently the most popular choice for building functional web tests in Drupal, in large part due to the development of robust Drupal-specific extensions in the open source community. This session will outline some best practices for using Behat and helpful tips for organization within this framework. Going beyond a simple introduction, we aim to add value by framing Behat as a tool for facilitating BDD and examining how this tool should fit into a larger testing infrastructure. The discussion will not be limited solely to Behat however, as we intend to explore other available tools for writing tests in Drupal. We will take a look at Codeception, a promising up and coming tool that is starting to get some support from the Drupal community. Finally, we will explore how Drupal 8’s testing frameworks fit into this broader strategy, including the new BrowerTestBase and KernelTestBase classes.
Along the way we will explore several key questions related to automated testing:
- What is the real value for adding automated tests to a web application?
- How much test coverage is enough?
- What should be tested? What should not be tested?
- Should we write functional tests, unit tests, or both?
- How can we scale our testing suites without creating a maintenance nightmare?