Behat stories are human-readable descriptions of how a website should behave, which can be used for automated testing.

Advantages:

Its automated

This means that with a click of a button, and a few minutes wait (depending on how many Behat tests you have), you get a clear list of site features and their test status.

Agreed requirements between clients and developers

Behat forces you to use the Behaviour Driven Development (BDD) process for software development. Through working with clients to define real examples of a how a feature could work you come to a mutual understanding.

Developers focus on solving the real problem

Once a developer has an understanding of what the client wants, along with executable acceptance criteria, they can simply go ahead and build the site feature, adding any functionality needed to make the test pass. Once the test passes the feature is ready for the review and deployment workflow.

Reliable Deployments

You simply run all tests against your staging site, which has been set up with your production database and release code, find any bugs, fix them, then repeat the process until all test features have passed and the release is stable. This provides you with confidence in the release process which your client will definitely appreciate.

Documentation

In writing clear, human readable, test features that describe individual site features, you end up with documentation in the form of an executable test feature.

Scenarios are written using the Gherkin language which is human readable following a simple structure of Given [some context] When [some event] Then [some outcome].

Your test suite then provides you with clear documentation of the site's features.

You will need to find a tool to get your information from test feature files into a readable document appropriate to your requirements. We recommend using a super simple tool called Pickles.

Disadvantages:

The only real disadvantage with Behat is that it does take time to implement, and requires you to rethink and possibly restructure your development process.

More time will also need to be spent with the developer and client to get the understanding needed to make sure the right problem is solved when features are built.

Summary of BDD and Behat

So to summarise BDD is a methodology aimed to bridge the communication gap between developers and clients using real examples of how a feature should work, and Behat is a tool that adds automated testing to the BDD software development process.

Ready for the bigger picture?

We recommend looking at these:

For more in-depth guidance on Behat and BDD come to one of our Quality Assurance training courses.