Your SlideShare is downloading. ×
Behaviour Driven Development
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Behaviour Driven Development


Published on

A talk about the why and how of Behaviour Driven Development. A life-demonstration of PHP-based Behat and Mink was included. …

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

  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

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!
  • Transcript

    • 1. Behaviour Driven Development Carsten Nielsen 2011-11-23
    • 2. Test Driven Development
      • Automation makes life easier
      • 3. Refactoring/extending becomes safer
      • 4. Faster development and better software
      Why? How can we test something theat don't exists? But hey! Test? It's about Design!
    • 5. It's Evolution Baby!
      • With ”Tests” we're designing the software/product.
      • 6. We're describing it's behaviour.
      Test Driven Development Behaviour Driven Development
    • 7. And there were Tests...
      • The customer wants us to build that awesome new video-portal with function X and technology Y and In The Cloud!
      • 8. We're talking with the customer about the How/When/Budget.
      • 9. The customer defines 2 gazillion pages of specs.
      • 10. We're sitting on the specs and start coding our tests.
      • 11. Project proceed...Tests passes...We're happy!.
      Is the customer happy? Oops! Design-Fail! What about the Why?
    • 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. Babelfish!
      • Use same vocabulary for
      Instead of code: And: Force them all think about the Why and Value!
    • 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. 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. Welcome to Planet Gherkin!
      • Domain Specific Language
      • 20. Create the vocabulary with your client
      • 21. Let the client write the stories/scenarios
      • 22. Let the client accept the scenarios
      • 23. Perfect for agile workflows
      • 24. Drop the spec-definition-bible and save some trees!
    • 25. A demonstration.
      • Behat – a BDD-framework for php
      • 26. Mink – an abstraction layer for browser-engines
      • 27. Test in any language you want!
        A terminal session is going to start – non-coders are allowed to take a mental break ;-)
    • 28. Go digging!
      • For PHP: Behat
      • 29. For Java: Jbehave
      • 30. For Ruby: Cucumber
      • 31. For Python: Lettuce
      • 32. For Perl: Test::Cukes
      • 33. Ahh - ok and for dotnet: SpecFlow
    • 34. Thanks!
      • Dan North –
      • 35. Konstantin Kudryashov –
      • 36. Carsten Nielsen @phreaknerd