SlideShare uma empresa Scribd logo
1 de 91
Baixar para ler offline
Enabling Agile
Through enabling BDD in PHP projects
Who?
BDD Evangelist
!
Creator of Behat, Mink, PhpSpec2,
Prophecy
!
Contributor to Symfony2, Composer
!
Host of the “Elephant in the Room”
podcast
BDD
– me, this month
BDD is a tool to bring structure
into the agile processes
Agile process
Out-of-the box
Agile process
Out-of-the box
BDD
In the Agile process
BDD is the
agile enabler
How does it
enable Agile?
Requirements
Analysis
Design
Development
Testing
9 months 3 m 2 m 12 m ...
[Royce 1970]
Most of the cost in
software development is
in the feedback delay
Lets reduce
feedback delay
Requirements
Acceptance
Testing
Coding
Refactoring
Weeks Minutes
[Beck & Cunningham 1996-99]
Requirements
Acceptance
Testing
?
Coding
Refactoring
[North 2003]
Weeks Minutes
Lets clarify
design intentions
Requirements
Acceptance
Specification
Implementation
Refactoring
[North 2003]
Weeks Minutes
Lets clarify
planning intentions
Adding value
What do you
mean?
Specification
Implementation
Refactoring
[North 2003]
Weeks Minutes
Adding value
What do you
mean?
Specification
Implementation
Refactoring
[North 2003]
Adding value
What do you
mean?
Specification
Implementation
Refactoring
[North 2003]
StoryBDD
SpecBDD
[North 2003]
Adding value
What do you
mean?
Specification
Implementation
Refactoring
Behat
PhpSpec
[North 2003]
Adding value
What do you
mean?
Specification
Implementation
Refactoring
StoryBDD
StoryBDD looks like a functional
TDD to the people from the outside
of the BDD community, but
it’s a simple confusion.
We are not testing that application
functions as we (developers) expect
it to, but instead we’re testing that
it fulfils our client business needs.
Some applications could easily fulfil
developers expectations and still not being
able to cover business needs.
You might think about StoryBDD as a
technique to teach your clients about
testing. In reality it's a tool to teach
you about your client business.
User-story
• Narrative
• Business rules
• Communication
• Acceptance criteria
User-story
• Narrative
• Business rules == AC
• Communication
User-story
• Narrative
• Business rules == AC
• Comm == Examples
User-story
• Narrative
• Business rules
• Comm == Examples == AC
StoryBDD splits every
feature in your project
into the 3 separate layers.
Each new layer adds
more information to the
table.
1
2
3
narrative
possible scenarios
scenario details
1
2
3
possible scenarios
scenario details
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
1
2
3scenario details
Scenario: Successfully authenticating
with correct credentials
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
1
2
3
Scenario: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
1
2
3
Example: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
Structure
In the Agile process
StoryBDD forces you to
answer questions you did
not know you need to ask.
1. Why?
aka: how to prioritise
my backlog
Feature: Authorisation
Why might your users
want this feature?
Feature: Authorisation
In order to get access to the shopping history
Feature: Authorisation
In order to get access to the shopping history
Who is mostly
interested in this
feature?
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
How can you help
him get this value?
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
benefit
beneficiar
Feature: Authorisation
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Feature: …
In order to …
As a …
I need to …
Feature: …
In order to …
As a …
I need to …
Feature: …
In order to …
As a …
I need to …
benefit
beneficiar
SELECT f.* as sprint
FROM ‘/features’ as f
ORDER BY f.role, f.benefit
LIMIT 10
PSEUDOAgileQL
2. What do you
mean?
aka: defining done through examples
How much “done” is
“done”?
How much of the
feature should be
delivered?
Scenario: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
Scenario: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
Given defines initial context
Scenario: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
When defines a user action (or state transition)
Scenario: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
Then defines an expected outcome
Scenario: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
And, But add more context, actions or outcomes
Scenario: Successfully authenticating
with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
!
3. When are we
done?
aka: closing feedback loop
assertEquals(Your Feature, Your App)
Setup
• Dump your sprint features into text files
• Put those text files into the `features/` folder inside
project
• Install behat (via composer or behat.phar)
• Initialize behat test suite by running `bin/behat —init`
Context
<?php
!
use BehatBehatContextClosuredContextInterface,
BehatBehatContextTranslatedContextInterface,
BehatBehatContextBehatContext,
BehatBehatExceptionPendingException;
use BehatGherkinNodePyStringNode,
BehatGherkinNodeTableNode;
!
class FeatureContext extends BehatContext
{
}
First run
$> bin/behat
...
You can implement step definitions for undefined steps with these snippets:
!
/**
* @Then I should see :arg1
*/
public function iShouldSee($arg1)
{
throw new PendingException();
}
...
Append snippets
$> bin/behat --append-snippets
Feedback loop
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
TODO: write pending definition
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
Stories
Examples
Describe
Implement
Design
Stories
Examples
Describe
Implement
Design
Colour it red.
Making it fail
/**
* @Given /^I am on the homepage$/
*/
public function iAmOnTheHomepage()
{
$crawler = new SomeCrawlerLibCrawler();
$crawler->goto(“http://localhost:8080/”);
if (200 !== $crawler->getCurrentStatusCode())
{
throw new RuntimeException(‘Can not open homepage’);
}
}
Making it fail
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Can not open homepage (RuntimeException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
Stories
Examples
Describe
Implement
Design
Change the message
As quickly as you can
Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Can not open homepage (RuntimeException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Route … not found (FrameworkException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Template … not found (FrameworkException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
When I follow “sign up”
TODO: write pending definition
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
Read more at
behat.org
Stories
Examples
Describe
Implement
Design
Spec-BDD
Stories
Examples
Describe
Implement
Design
Spec-BDD
Stories
Examples
Describe
Implement
Design
Spec-BDD
Stories
Examples
Describe
Implement
Design
Read more at
phpspec.net
That’s all nice
theoretical stuff
http://inviqa.com/careers
Thank you!

Mais conteúdo relacionado

Mais procurados

Mais procurados (18)

Php Tutorial | Introduction Demo | Basics
 Php Tutorial | Introduction Demo | Basics Php Tutorial | Introduction Demo | Basics
Php Tutorial | Introduction Demo | Basics
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018
 
Quality code by design
Quality code by designQuality code by design
Quality code by design
 
I Love codeigniter, You?
I Love codeigniter, You?I Love codeigniter, You?
I Love codeigniter, You?
 
Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)
 
Phone calls and sms from php
Phone calls and sms from phpPhone calls and sms from php
Phone calls and sms from php
 
Eugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryEugene Andruszczenko: jQuery
Eugene Andruszczenko: jQuery
 
Disregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_FormDisregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_Form
 
Testing ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using RubyTesting ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using Ruby
 
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS»  QADay 2019МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS»  QADay 2019
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
 
Best practices for crafting high quality PHP apps (PHP Yorkshire 2018)
Best practices for crafting high quality PHP apps (PHP Yorkshire 2018)Best practices for crafting high quality PHP apps (PHP Yorkshire 2018)
Best practices for crafting high quality PHP apps (PHP Yorkshire 2018)
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
Crafting Quality PHP Applications: an overview (PHPSW March 2018)
Crafting Quality PHP Applications: an overview (PHPSW March 2018)Crafting Quality PHP Applications: an overview (PHPSW March 2018)
Crafting Quality PHP Applications: an overview (PHPSW March 2018)
 
Amazon IoT Cloud
Amazon IoT CloudAmazon IoT Cloud
Amazon IoT Cloud
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
IoC with PHP
IoC with PHPIoC with PHP
IoC with PHP
 
Api
ApiApi
Api
 

Destaque

Destaque (12)

Modern Project Toolbox
Modern Project ToolboxModern Project Toolbox
Modern Project Toolbox
 
Being effective with legacy projects
Being effective with legacy projectsBeing effective with legacy projects
Being effective with legacy projects
 
Min-Maxing Software Costs
Min-Maxing Software CostsMin-Maxing Software Costs
Min-Maxing Software Costs
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDD
 
BDD в PHP с Behat и Mink
BDD в PHP с Behat и MinkBDD в PHP с Behat и Mink
BDD в PHP с Behat и Mink
 
BDD для PHP проектов
BDD для PHP проектовBDD для PHP проектов
BDD для PHP проектов
 
Modern Agile Project Toolbox
Modern Agile Project ToolboxModern Agile Project Toolbox
Modern Agile Project Toolbox
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
 
Bridging The Communication Gap, Fast
Bridging The Communication Gap, Fast Bridging The Communication Gap, Fast
Bridging The Communication Gap, Fast
 
Moving away from legacy code (AgileCymru)
Moving away from legacy code  (AgileCymru)Moving away from legacy code  (AgileCymru)
Moving away from legacy code (AgileCymru)
 
Taking back BDD
Taking back BDDTaking back BDD
Taking back BDD
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mocking
 

Semelhante a Enabling agile devliery through enabling BDD in PHP projects

Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
Brandon Keepers
 

Semelhante a Enabling agile devliery through enabling BDD in PHP projects (20)

Behat for writing tests in a stylized way
Behat for writing tests in a stylized wayBehat for writing tests in a stylized way
Behat for writing tests in a stylized way
 
Introduce cucumber
Introduce cucumberIntroduce cucumber
Introduce cucumber
 
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
 
I put on my mink and wizard behat - Confoo Canada
I put on my mink and wizard behat - Confoo CanadaI put on my mink and wizard behat - Confoo Canada
I put on my mink and wizard behat - Confoo Canada
 
I put on my mink and wizard behat (talk)
I put on my mink and wizard behat (talk)I put on my mink and wizard behat (talk)
I put on my mink and wizard behat (talk)
 
Transformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoTransformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicação
 
I put on my mink and wizard behat
I put on my mink and wizard behatI put on my mink and wizard behat
I put on my mink and wizard behat
 
How to improve our acceptance tests - Pyccuracy VS Splinter
How to improve our acceptance tests - Pyccuracy VS SplinterHow to improve our acceptance tests - Pyccuracy VS Splinter
How to improve our acceptance tests - Pyccuracy VS Splinter
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
 
Quick ref capybara
Quick ref capybaraQuick ref capybara
Quick ref capybara
 
Quick ref capybara
Quick ref capybaraQuick ref capybara
Quick ref capybara
 
Behat
BehatBehat
Behat
 
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It WrongController Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrong
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
BDD - Collaborate like you mean it!
BDD - Collaborate like you mean it!BDD - Collaborate like you mean it!
BDD - Collaborate like you mean it!
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
 
Passwords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answerPasswords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answer
 
Behavioral Driven Development
Behavioral Driven Development Behavioral Driven Development
Behavioral Driven Development
 

Último

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Enabling agile devliery through enabling BDD in PHP projects