Perl Behavior Driven Development (BDD)
Upcoming SlideShare
Loading in...5
×
 

Perl Behavior Driven Development (BDD)

on

  • 2,814 views

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

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

Statistics

Views

Total Views
2,814
Views on SlideShare
2,774
Embed Views
40

Actions

Likes
2
Downloads
12
Comments
0

2 Embeds 40

http://coderwall.com 35
https://twitter.com 5

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Perl Behavior Driven Development (BDD) Perl Behavior Driven Development (BDD) Presentation Transcript

  • Behavior DrivenDevelopment inPerlTudor Constantin - perl hacker @ Evozon
  • Contents● Objectives● TDD and its disadvantages● How BDD works● BDD and The Mojolicious-Boilerplate● Wishlist● Conclusions● References
  • 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
  • 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 Test::BDD::Cucumber
  • 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)
  • 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
  • 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
  • How BDD Works2. The developer implements each stepExample of Implementation for the stepGivena mojo test object for the"Boilerplate" application
  • 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" ); };
  • 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
  • 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, 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
  • 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
  • References● http://en.wikipedia.org/wiki/Behavior_Driven_Development● Peter Sergeants Test::BDD::Cucumber::Manual::Tutorial● Mojolicious Boilerplate● Story Driven Development With Cucumber