Technology

Complex projects cannot afford to skip automated testing

Automated testing has been taken relatively lightly in the Drupal community over the years. So I wanted to spend some time exploring Behat testing and what benefits it brings to project delivery. 

Daniel Sipos
Daniel Sipos

Automated testing has been taken relatively lightly in the Drupal community over the years. It was an added complication, developers were unfamiliar with it, clients wouldn't understand it (and therefore wouldn't pay for it) and shops didn't want to invest in it.

So unlike other major software projects, a type of vicious circle prevented the organic growth of automated testing within the Drupal community.

The realities have changed.

For example, contribution to core has made it so people (at least those who contribute) are forced to write tests for the code they submit. And the number of contributors has increased with Drupal 8. More importantly, though, the growing focus on enterprise Drupal "products" has highlighted both the need and the benefits of protecting software with automated testing.

At Wunderkraut we recognise this importance. Smoke screen and behaviour testing ensure that some of our more complex projects go through their development life cycles with minimal regressions.

Aside from the self-evident benefits, it's worth noting the positive impact it has on minimising the overhead of handling UAT defects in the development cycle. Moreover, backed by a sensible suite of tests, our developers can work much more efficiently on new features. It becomes almost a pleasure catching regressions while developing and running the test suite.

To help us with this, one of our favourite automated testing tools is Behat, a Behaviour Driven Development (BDD) oriented framework.

In a nutshell, BDD focuses on outlining scenarios of how the software should behave (mostly in the browser in our case) and running automated tests for these scenarios against the software.

This allows us to closely engage with the stakeholders to define how their end users should interact with the website and capture this in Behat scenarios. The actual functionality is then built to match the expected behaviours outlined in said scenarios.

Lastly, the growing test suite ensures that previously defined functionality keeps running as expected even after "a while" or new behaviours have been added.

Behat testing code