Behaviour Driven Development Carsten Nielsen 2011-11-23
Test Driven Development <ul><li>Automation makes life easier
Refactoring/extending becomes safer
Faster development  and better software </li></ul>Why? How can we test something theat don't exists? But hey! Test? It's a...
It's Evolution Baby! <ul><li>With ”Tests” we're designing the software/product.
We're describing it's behaviour. </li></ul>Test Driven Development Behaviour Driven Development
And there were Tests... <ul><li>The customer wants us to build that awesome new video-portal with function X and technolog...
We're talking with the customer about the How/When/Budget.
The customer defines 2 gazillion pages of specs.
We're sitting on the specs and start coding our tests.
Project proceed...Tests passes...We're happy!. </li></ul>Is the customer happy? Oops! Design-Fail! What about the Why?
Obscured by code Is this readable, understandable and acceptable?  class FixturesTest extends sfPHPUnitBaseTestCase { publ...
Upcoming SlideShare
Loading in …5
×

Behaviour Driven Development

1,450 views
1,399 views

Published on

A talk about the why and how of Behaviour Driven Development. A life-demonstration of PHP-based Behat and Mink was included.
Held at the Redpill Linpro Gathering 2011 in Sunne.

Published in: Technology, Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,450
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • Carsten Nielsen: php-utvecklare jobba mycket med open source cms som Contao, drupal, mediawiki, typo3 eller applikationsutveckling med php/symfony Vad är BDD? Det baserar på TDD
  • Dem vanliga argument för tester Dan North kom på den «oligiska» slutsatsen i TDD att man kan inte testa något some inte finns.
  • Test Driven Design - Unit-Test focussera på code (testa en class) - Functional test focussera på applikationens beteende Tå bort test och skriv behaviour och det är enklare att första vad det är. En kombination av funktionellt och akseptans-test Vi har ju allt. Varför en ny concept?
  • Ett vanligt exempel... Kunden skriver hur databasen ska se ut? Verkligen? Vad har hänt? No definition about the value of a feature! Vi skrev «tester» som vi tyckte uppfyller kundens mål.
  • Ett vanligt test ser sohär ut. Fatter en kund dethär? Finns det ett Value? Nej! Men här kommer en Babelfish...
  • Vi behöver ett gemensamt språk. Userstories to the rescue!
  • Det här definerar värdet av vart feature. Nu behöver vi scenarier som hjälpa oss nå det här värdet och undvika fel. Scenarios!
  • Du har just lärt dig ett nytt språk!
  • Behaviour Driven Development

    1. 1. Behaviour Driven Development Carsten Nielsen 2011-11-23
    2. 2. Test Driven Development <ul><li>Automation makes life easier
    3. 3. Refactoring/extending becomes safer
    4. 4. Faster development and better software </li></ul>Why? How can we test something theat don't exists? But hey! Test? It's about Design!
    5. 5. It's Evolution Baby! <ul><li>With ”Tests” we're designing the software/product.
    6. 6. We're describing it's behaviour. </li></ul>Test Driven Development Behaviour Driven Development
    7. 7. And there were Tests... <ul><li>The customer wants us to build that awesome new video-portal with function X and technology Y and In The Cloud!
    8. 8. We're talking with the customer about the How/When/Budget.
    9. 9. The customer defines 2 gazillion pages of specs.
    10. 10. We're sitting on the specs and start coding our tests.
    11. 11. Project proceed...Tests passes...We're happy!. </li></ul>Is the customer happy? Oops! Design-Fail! What about the Why?
    12. 12. Obscured by code Is this readable, understandable and acceptable? class FixturesTest extends sfPHPUnitBaseTestCase { public function _start() { new sfDatabaseManager(ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true)); Doctrine_Core::loadData(sfConfig::get('sf_data_dir').'/fixtures'); }   public function test1() { $name = 'foo'; $model = Doctrine::getTable('SomeModel')->findByName($name); $this->assertTrue( is_object ($model)); $this->assertEquals('SomeModel', get_class ($model)); $this->assertEquals($name, $model['name']); } } Can the customer understand this?
    13. 13. Babelfish! <ul><li>Use same vocabulary for </li><ul><li>Developers
    14. 14. Testers
    15. 15. Analysts
    16. 16. and our Customers! </li></ul></ul>Instead of code: And: Force them all think about the Why and Value!
    17. 17. Once upon a time... A userstory: Editor can login As a editor I want to be able to login into the backend So that I can edit my personal events Thats a role, an action and a value. In order to edit my personal events As a editor I need to be able to login into the backend Yes! Value! Alternative pattern with focus on value:
    18. 18. Desire! Tension! Action! A scenario: Login as reistered user Given I am on «/login» When I fill in «username» with «slartibartfass» And I fill in «password» with «42» Then I should see «Welcome!» And I should not see «Login» And this is testable – readable - usable! Other language needed? Givet jag är på «/login» När jag fylla in «username» med «slartibartfass» Och jag fylla in «password» med «42» Då skulle jag se «Welcome!»
    19. 19. Welcome to Planet Gherkin! <ul><li>Domain Specific Language
    20. 20. Create the vocabulary with your client
    21. 21. Let the client write the stories/scenarios
    22. 22. Let the client accept the scenarios
    23. 23. Perfect for agile workflows
    24. 24. Drop the spec-definition-bible and save some trees! </li></ul>
    25. 25. A demonstration. <ul><li>Behat – a BDD-framework for php
    26. 26. Mink – an abstraction layer for browser-engines
    27. 27. Test in any language you want! </li></ul>Attention! <ul>A terminal session is going to start – non-coders are allowed to take a mental break ;-) </ul>
    28. 28. Go digging! <ul><li>For PHP: Behat
    29. 29. For Java: Jbehave
    30. 30. For Ruby: Cucumber
    31. 31. For Python: Lettuce
    32. 32. For Perl: Test::Cukes
    33. 33. Ahh - ok and for dotnet: SpecFlow </li></ul>
    34. 34. Thanks! <ul>Ressources: <li>Dan North – www.dannorth.net
    35. 35. Konstantin Kudryashov – www.everzet.com
    36. 36. www.behat.org Carsten Nielsen carsten@redpill-linpro.com @phreaknerd </li></ul>

    ×