Behavior DrivenDevelopment inPerlTudor Constantin - perl hacker @ Evozon
Contents● Objectives●   TDD and its disadvantages●   How BDD works●   BDD and The Mojolicious-Boilerplate●   Wishlist●   C...
ObjectivesAssuming you have the following user story toimplement:Feature: Standard Signup    In order to begin using the a...
ObjectivesFollowing TDD, youd have to start writing teststhat will guarantee your app functionality
ObjectivesObjective achievedWith BDD, that user story IS your test suite forthat scenarioPerl BDD Module:● Peter Sergeants...
ObjectivesFeature: Standard Signup    In order to begin using the application    As a new user    I want to create an acco...
TDD and its disadvantages●   Where to start●   What to test and what not to test●   How much to test in one go●   What nam...
How BDD Works1. Stakeholders write a formal user story   a. Feature section - free form text describing that      particul...
How BDD Works2. The developer implements each stepExample of Implementation for the stepGivena mojo test object for the"Bo...
How BDD WorksGiven qr/a mojo test object for the "(.+)"application/, func ($c) {  use_ok( $1 );  my $tm = Test::Mojo->new(...
BDD and The Mojolicious-Boilerplate● Started using BDD as the way to test apps  using the Mojolicious-Boilerplate● There a...
BDD and The Mojolicious-BoilerplateScenario file: Mojolicious-Boilerplate / t / features /   mojo.feature
BDD and The Mojolicious-BoilerplateSteps File: Mojolicious-Boilerplate / t / features / step_definitions /   mojo_steps.pl
Wishlist Road Map● Create more scenarios/user-stories● Find a way to get a more convenient map  between Mojolicious Routes...
Conclusions● easy way to get started in writing tests● test-scenarios and tests are self documented● natural way of logica...
References●   http://en.wikipedia.org/wiki/Behavior_Driven_Development●   Peter Sergeants Test::BDD::Cucumber::Manual::Tut...
Upcoming SlideShare
Loading in …5
×

Perl Behavior Driven Development (BDD)

3,191 views
3,001 views

Published on

Introduction to Perl Behavior Driven Development. The objective is to have the business analysts write tests for you in the form of user-stories.

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

No Downloads
Views
Total views
3,191
On SlideShare
0
From Embeds
0
Number of Embeds
48
Actions
Shares
0
Downloads
18
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Perl Behavior Driven Development (BDD)

  1. 1. Behavior DrivenDevelopment inPerlTudor Constantin - perl hacker @ Evozon
  2. 2. Contents● Objectives● TDD and its disadvantages● How BDD works● BDD and The Mojolicious-Boilerplate● Wishlist● Conclusions● References
  3. 3. ObjectivesAssuming you have the following user story toimplement:Feature: Standard Signup In order to begin using the application As a new user I want to create an accountScenario: Signup with valid email/password combination Given I do not have an account When I signup with email and password Then I should be logged in And my profile details should be filled in
  4. 4. ObjectivesFollowing TDD, youd have to start writing teststhat will guarantee your app functionality
  5. 5. ObjectivesObjective achievedWith BDD, that user story IS your test suite forthat scenarioPerl BDD Module:● Peter Sergeants Test::BDD::Cucumber
  6. 6. ObjectivesFeature: Standard Signup In order to begin using the application As a new user I want to create an accountScenario: Signup with valid email/password combination Given I do not have an account When I signup with email and password Then I should be logged in And my profile details should be filled inLegend:(this text is parsed by the BDD framework)(your actual test knows what to do with this text)
  7. 7. TDD and its disadvantages● Where to start● What to test and what not to test● How much to test in one go● What name should that test have● How to organize the tests in files● How to setup and share context between tests
  8. 8. How BDD Works1. Stakeholders write a formal user story a. Feature section - free form text describing that particular feature of the application b. Background section - parsable text meant to set up the context for testing that feature - ex: "Given I am logged in as administrator" i. each Feature might have a Background section c. Scenario(s) section(s) i. each feature has one or more scenarios d. Steps i. each scenario has one or more steps
  9. 9. How BDD Works2. The developer implements each stepExample of Implementation for the stepGivena mojo test object for the"Boilerplate" application
  10. 10. How BDD WorksGiven qr/a mojo test object for the "(.+)"application/, func ($c) { use_ok( $1 ); my $tm = Test::Mojo->new( $1 ); ok( $tm, "Object created" ); $c->stash->{feature}->{tm} = $tm; ok( $c->stash->{feature}->{tm}, "Gotour Test::Mojo object" ); };
  11. 11. BDD and The Mojolicious-Boilerplate● Started using BDD as the way to test apps using the Mojolicious-Boilerplate● There are passing scenarios● There are failing scenarios● Get involved and take on the opportunity to learn BDD in practice
  12. 12. BDD and The Mojolicious-BoilerplateScenario file: Mojolicious-Boilerplate / t / features / mojo.feature
  13. 13. BDD and The Mojolicious-BoilerplateSteps File: Mojolicious-Boilerplate / t / features / step_definitions / mojo_steps.pl
  14. 14. Wishlist Road Map● Create more scenarios/user-stories● Find a way to get a more convenient map between Mojolicious Routes, URL display text and URL value● Create a Bootstrap-specific grammar ○ will make the testing process even less "programmer bound" ○ most HTML elements are contained in tags with Bootstrap specific css classes● More, better documentation
  15. 15. Conclusions● easy way to get started in writing tests● test-scenarios and tests are self documented● natural way of logically split the test files into functionality related files/folders/objects
  16. 16. References● http://en.wikipedia.org/wiki/Behavior_Driven_Development● Peter Sergeants Test::BDD::Cucumber::Manual::Tutorial● Mojolicious Boilerplate● Story Driven Development With Cucumber

×