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.
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?
16. and our Customers! 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!»
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!