2. Contents
● Objectives
● TDD and its disadvantages
● How BDD works
● BDD and The Mojolicious-Boilerplate
● Wishlist
● Conclusions
● References
3. Objectives
Assuming you have the following user story to
implement:
Feature: Standard Signup
In order to begin using the application
As a new user
I want to create an account
Scenario: 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
6. Objectives
Feature: Standard Signup
In order to begin using the application
As a new user
I want to create an account
Scenario: 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
Legend:
(this text is parsed by the BDD framework)
(your actual test knows what to do with this text)
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. How BDD Works
1. 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. How BDD Works
2. The developer implements each step
Example of Implementation for the step
'Givena mojo test object for the
"Boilerplate" application'
10. How BDD Works
Given 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'}, "Got
our Test::Mojo object" );
};
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. BDD and The Mojolicious-Boilerplate
Scenario file: Mojolicious-Boilerplate / t / features / mojo.feature
13. BDD and The Mojolicious-Boilerplate
Steps File: Mojolicious-Boilerplate / t / features / step_definitions / mojo_steps.pl
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. 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. References
● http://en.wikipedia.org/wiki/Behavior_Driven_Development
● Peter Sergeant's Test::BDD::Cucumber::Manual::Tutorial
● Mojolicious Boilerplate
● Story Driven Development With Cucumber