Php user group March 2013 - BeHat.

in php, testing, gherkin, behat

Background.

On Monday the 31st of March I attended the Cambridge PHP Meetup, the topic was BeHat testing. Johnathan Gough gave the talk.

This is something we are getting started with in eLife. We have a few small tests in place, we have a few regressions on the site that we want to tackle, and we are looking to use it as a way of pinning down requirements from the company for new features that we want to roll out. After attending this talk I also found this great blog post on why BDD is the world’s most misunderstood collabroation tool.

NOTES:

An interesting thing is that behat will create a /bin directory in the project directory. (I wonder whether that is something that can be set to system level, probably. (I would image that would be much nicer)).

behat creates a /features directory.

Behat lives in a universe of other tools, it sits on top of Behat Context and Mink Context. The Behat Context is a vanilla file in which you write your own context for how behat should interpret the tests. Mink provides web browser functionality. It can sit on top of

If you are using a framework, you can fire up the framework, inject the request, and get the response out, and this kind of customisation is available to people writing their own contexts. An open question is whether one can mock up Drupal requests to insert into the manual contextual scripts.

Mink exposes descriptive commands that you can use to describe how your web application should work.

You can specify at the level of an individual tests or scenarios as to which context that scenario should use (that sounds potentially really useful).

Bottom line, Behat makes testing a lot easier, makes testing fun, and can be quite revolutionary.

Questions: