Date post: | 08-Aug-2015 |
Category: |
Technology |
Upload: | the-software-house |
View: | 765 times |
Download: | 1 times |
tekst
BDD vs BehatPaweł Skotnicki
About me
PHP developer @ The Software House
PHPers Silesia co-organizer
BDD/DDD enthusiast
BDD
Behaviour Driven Development
Dan North, 2003
BDD is like TDD without world „test”
examples in ubiquitous language
using those examples as the basis of automated tests
BDD main parts
Scenarios
writing down is NOT most important part
conversation
Behat
an open source BDD framework for PHP
Gherkin language
Given, When, Then
Behat !== BDD
BDD = scenarios + automation
Behat = automation tool
Better scenarios?
Imperative vs Declarative
Imperative
reusable granular steps
binds to UI
Declarative
business language
Mink Extension example
ImperativeFeature: Search In order to see a word definition As a website user I need to be able to search for a word
Scenario: Searching for a page that does exist Given I am on "/wiki/Main_Page" When I fill in "search" with "Behavior Driven Development" And I press "searchButton" Then I should see "agile software development"
Feature: Search In order to see a word definition As a website user I need to be able to search for a word
Scenario: Searching for a page that does exist Given there is „Behavior Driven Development” article
And there is „agile software development” article When I search for "Behavior Driven Development" Then there should be "agile software development” reference
Declarative
ImperativeScenario: Registering with already used e-mail Given there are following users: | username | password | email | active | | testuser1 | test1 | [email protected] | 1 |
When I am on „/register” page And I fill in „username” with „newuser” And I fill in „password” with „123456” And I fill in „email” with „[email protected]” And I press „register” Then I should see „e-mail is already used”
Declarative
Scenario: Registering with already used e-mail Given there is registered user with „[email protected]” e-mail When I try to register with „[email protected]” e-mail Then I should be notified that e-mail is already used
Scenario: Purchasing a product Given there is „Lightsaber” which costs $5 When I add „Lightsaber” to basket Then there should be „Lightsaber” in my basket When I check out my basket Then I should be charged for $5
Many activities
Scenario: Adding product to basket Given there is „Lightsaber” When I add „Lightsaber” to basket Then there should be „Lightsaber” in my basket
Scenario: Checking out basket Given there is „Lightsaber” which costs $5 in my basket When I check out my basket Then I should be charged for $5
One activity
Tips
avoid implementation details
use ubiquitous language
ask for examples
describe one activity
Questions?
Thank you