Behavior Driven Development (BDD) is a software engineering practice designed to help teams build and deliver more valuable, higher quality software faster.
It is not about programming, testing or management. It's about building together.
2. Project restarts
One of the major causes of both cost and time
overruns is restarts.
For every 100 projects that start, there are 94
restarts. This does not mean that 94 of 100 will
have one restart, some projects can have
several restarts.
src: http://www.projectsmart.co.uk/docs/chaos-report.pdf
3. What is BDD?
Behavior Driven Development (BDD) is a
software engineering practice designed to help
teams build and deliver more valuable, higher
quality software faster.
It is not about programming, testing or
management.
It's about building together.
4. Building together
To do this, we need a way to
describe the requirement such
that everyone
● the business folks (customer)
● the product owner
● the development team
have a common understanding
of the scope of the work.
source: http://dannorth.net/whats-in-a-story/
6. Use case
It would be great if we could connect multiple advertisement
agents worldwide. Then visitors can see local advertisements.
Feature: Local advertisements for visitors
In order to see local advertisements,
As a Visitor I want the website to detect my country settings,
So that the right Advertising agent will serve my advertisements
7. Present the story to the dev team
The Visitor doesn't benefit from this feature, but the Advertising
traffickers. They will have full control over country based
advertisements. How about control on channels?
Feature: Country Based Advertisement Serving on portals
In order to be able to serve advertisements by different agents
As a Advertising trafficker
I want define the agent based on the country and channel
8. Making the boss happy
I love you guys. This will bring in even more $ money $.
While you're on it please add support for pages as well....
Feature: Country Based Advertisement Serving on portals
In order to be able to serve advertisements by different agents
As a Advertising trafficker
I want define the agent based on the country, channel and page
9. Writing the story
Feature: Country Based Advertisement Serving on portals
In order to be able to serve advertisements by different agents
As a Advertising trafficker
I want define the agent based on the country, portal and page
10. Refining the story
Feature: Country Based Advertisement Serving on portals
In order to be able to serve advertisements by different agents
As a Advertising trafficker
I want define the agent based on the country, portal and page
Scenario Outline: Visitors on certain channel pages
Given the visitor is from "<country>"
When the visitor is on the "<page>" page
And the visitor is on the "<channel>" channel
Then advertisements should be served by <agent>
Examples:
#######################################################
| country | page | channel | agent |
#######################################################
| default | default | default | Google |
| The Netherlands | home | default | Google |
| America | game | Family | AdTech |
| America | home | Teens | StarMedia |
| America | home | Girls | Google |
12. Generated snippet
<?php
use BehatBehatTesterExceptionPendingException;
use BehatMinkExtensionContextMinkContext;
use BehatBehatContextSnippetAcceptingContext;
class WebContext extends MinkContext implements SnippetAcceptingContext
{
/**
* @Given the visitor is from :arg1
*/
public function theVisitorIsFrom($arg1)
{
throw new PendingException();
}
/**
* @When the visitor is on the :arg1 page
*/
public function theVisitorIsOnThePage($arg1)
{
throw new PendingException();
}
/**
* @When the visitor is on the :arg1 channel
*/
public function theVisitorIsOnTheChannel($arg1)
{
throw new PendingException();
}
/**
* @Then advertisements should be served by :provider
*/
public function advertisementsShouldBeServedBy($provider)
{
throw new PendingException();
}
}
13. Enter some logic
<?php
use BehatBehatTesterExceptionPendingException;
use BehatMinkExtensionContextMinkContext;
use BehatBehatContextSnippetAcceptingContext;
class WebContext extends MinkContext implements SnippetAcceptingContext
{
private $pages = array(
'default' => '/',
'home' => '/',
'game' => '/spel/donuts-saras-kookcursus'
);
private $channels = array(
'Teens' => 'http://www.agame.com',
'Girls' => 'http://www.girlsgogames.com',
'Family' => 'http://spel.nl'
);
/**
* @Given the visitor is from :country
*/
public function theVisitorIsFrom($country)
{
$this->getSession()->setCookie('country', $country);
}
/**
* @When the visitor is on the :page page
*/
public function theVisitorIsOnThePage($page)
{
$this->visitPath($this->pages[$page]);
}
/**
* @When the visitor is on the :arg1 channel
*/
public function theVisitorIsOnTheChannel($channel)
{
$this->setMinkParameter('base_url', $this->channels[$channel]);
}
/**
* @Then advertisements should be served by :provider
*/
public function advertisementsShouldBeServedBy($provider)
{
// provider check...
}
}