Tuesday 25 January 2011

sfBehatPlugin - BDD for symfony

I just installed sfBehatPlugin, a behat plugin for symfony.

Tip: if behat isn't finding the steps that come with sfBehatPlugin and you're getting:


$ behat features/
Feature: auth

Scenario: Index page # features/frontend/auth.feature:3
Given I am on homepage
When I go to /auth
Then Response status code is 200
And I should see "This is a temporary page"

1 scenario (1 undefined)
4 steps (4 undefined)
0.035s

You can implement step definitions for undefined steps with these snippets:

$steps->Given('/^I am on homepage$/', function($world) {
throw new \Everzet\Behat\Exception\Pending();
});

$steps->When('/^I go to /auth$/', function($world) {
throw new \Everzet\Behat\Exception\Pending();
});

$steps->Then('/^Response status code is (\d+)$/', function($world, $arg1) {
throw new \Everzet\Behat\Exception\Pending();
});

$steps->And('/^I should see "([^"]*)"$/', function($world, $arg1) {
throw new \Everzet\Behat\Exception\Pending();
});


Try running it from the root of your symfony project, with no params:

$ behat
Feature: auth

Scenario: Index page # features/frontend/auth.feature:3
Given I am on homepage # features/steps/tester_browser_steps.php:13
When I go to /auth # features/steps/tester_browser_steps.php:17
Then Response status code is 200 # features/steps/tester_response_steps.php:13
And I should see "This is a temporary page" # features/steps/tester_response_steps.php:17

1 scenario (1 passed)
4 steps (4 passed)
0.288s