Behat
[image source: "Männer in Harnisch" by Jiří Winter Neprakta; Artia, Prague © 1972 ]
What It Is
- BDD framework for in PHP
- Open Source (MIT License)
- Inspired by Cucumber
- Behat test are functional tests
How To Use It
Write your user stories ( Features and Scenarios ) in a human-readable format ( Gerkin language ).
Feature: Some terse yet descriptive text of what is desired In order to realize a named business value As an explicit system actor I want to gain some beneficial outcome which furthers the goal Scenario: Some determinable business situation Given some precondition And some other precondition When some action by the actor And some other action And yet another action Then some testable outcome is achieved And something else we can check happens too
Back up your stories with code (Step Definitions).
<?php /** * @Then /^some testable outcome is achieved$/ */ public function assertSomeTestableOutcomeIsAchieved() { // make your assertion here, // if it fails throw an exception }
Run it.
The Stack
- Behat
- Mink
- sister project to Behat
- provides web driver integration for Behat
- pluggable (Goutte, Selenium, ZombieJS, others)
- Selenium WebDriver
- Open Source web driver
- emulates user behaviour in web browsers
- Java
- takes input from Mink
- works with any number of browsers (FF, Chrome, IE, Safari)
- PhantomJS
- open source headless web browser
- requires Node.js
- can be integrated with Selenium