Behat 2.2: Bunch of new features

Published on

Dec 13, 2011

knp

Dec 14, 2011 − Yeehoo, it's here! Behat 2.2 is finally released and has amazing new features for you to play with. "Multiple formats output", "Output color settings", "Couple of new formatters" if this all means something to you - continue reading.

Yeehoo, it's here! Behat 2.2 is finally released and has amazing new features for you to play with. "Multiple formats output", "Output color settings", "Couple of new formatters" if this all means something to you - continue reading.

The biggest change since 2.1 is infrastructure migration. Now Behat uses Travis CI for its continuous testing. And i'm happy to announce that Behat and Gherkin are now parts of growing Packagist family. Yep, you can finally install Behat with this shiny new Composer thing.

Next in the line is the most requested feature from Behat users:

Multiple formats output

Ever wanted to use 2 formats at the same time? Here you are:

behat -f pretty,progress

multiformat with single output

Not too useful, right? Or is it???

multiformat with multiple outputs

Yep, you can provide multiple outputs too. Split both formats and outputs with ,. Empty outputs will be printed to stdout.

Outputting with progress to console, html to behat.html and junit to xml folder command will look like this:

behat -f progress,html,junit --out ,behat.html,xml

Easy, right?

--dry-run option

Ever wanted to print your entire feature suite without executing any underlying code? Want to just print snippets without waiting suite to gets executed? --dry-run to rescue:

dry-run

Extended --definitions option

Now --definitions always expects value to be providen, because it can print definitions in different styles:

  • to just print list of definitions - use -dl (Definitions List).
  • to print definitions with extended info - use -di (Definitions Info).
  • to search for specific definition - use -d 'search string'.

definitions

failed formatter

Want a list of failed scenarios paths? Here you are:

failed

This formatter is also used internally by --rerun option.

snippets formatter

This little helper prints only snippets without any other steps information:

snippets

--append-snippets option

And I went even further with snippets formatter. Now you have magic --append-snippets option. When used, this option makes Behat to automatically append snippets into your main context class. How cool is that?

Refactoring and other small features

There are even cooler small features in this release, but I will let you to discover them yourself ;-)

Plugin system

Starting from 2.2 Behat have a powerful plugin system, that could be used to extend/overhaul Behat internals.

Upgrade

Use PEAR, new PHAR package or brand new Composer package.

BehatBundle

BehatBundle needs to be updated in order to work with Behat 2.2. So if you're using BehatBundle in your project - just wait a little with upgrade ;-)

Learning

You like Behat but don't know how to start with it? Or you just need to explore Behat internals with its creators? Attend the first BDD/Behat training in Paris

Written by

KNP Labs
KNP Labs

Comments