Everyone falls in love with Behat. It’s powerfull tool for testing business requirements in PHP. Behat scenarios, written in cross-platform Gherkin language, are readable for developers, easy to understand and verify for business people and executable by machine, which goes through an application to prove that it works as expected.

Behat scenarios are one of the best ways to describe system. UML Use Cases or tons of pages in SRS documents are fine, but hard to understand from the begining, and even harder to maintain in the future. Behat eases this process and also gives opportunity to automate requirements verification.

To write Behat scenarios you need a text editor. I’ve picked my favourite – Vim, which highlights *.feature files syntax. But business people mostly don’t use Vim, so I need to figure a way, to expose scenarios in easy and pleasant way. There are few steps to get it done:

  1. Merge all features in one file
  2. Open it in Vim
  3. Make hardcopy
  4. Convert hardcopy output (PostScript) to PDF
  5. Send it to customer :-)

Here’s how we do it from technical point of view:

1. Find all feature files and cat them to one file (assuming your .feature files are located somewhere in src/ directory)

find src/ -name *.feature | xargs cat >> system_requirements.feature

2. Open Vim and configure some printing options

:set printfont=courier:h8
:set printencoding=latin2
:colorscheme default

Some remarks:

  • font is platform dependant, you should adjust it by yourself
  • printencoding set to latin2 is required for polish encoding (even if features were written in UTF8)
  • colorscheme is also a matter of taste, default one looks good in PDF

3. Now we are ready to create hardcopy, which is simple print to the PostScript file:

:hardcopy > system_requirements.ps

4. In terminal convert *.ps file to PDF (or whatever else format you like):

$ ps2pdf system_requirements.ps

5. Et voilà, your PDF is ready to send to the customer, example can be seen below

Behat scenarios in PDF