It's not obvious what the stake holders really want. How do you know what tests to write? How to you know that you've written the last test? Are you writing the correct code? These are all questions that developers have to answer on a daily basis. BDD can help you and your PO answers these questions faster and with more accuracy. Behat is the BDD framework for PHP that makes it easy to get started with your feature development.
2. Isn’t it obvious…???
○
What test should I write next?
○
How do I know when I’ve written the last test?
○
Am I writing the right code?
4. “
If you can't explain it simply, you
don't understand it well enough
!
Albert Einstein
”
5. Why BDD?
○
Write Human-readable stories that describe the behaviour of your application
○
Focuses the communication between the business and the developers
○
Code is self documenting
○
Code is easier to maintain
8. Feature - Gherkins
# features/BananaCalculator.features
# Describe the business value of this feature
Feature: Banana Calculator
As Bob the Banana merchant,
I want a calculator that can add the amount of bananas
so that I can know how many bananas I currently have
9. Scenario - Gherkins
# features/BananaCalculator.features
# Describe the business rules with scenarios
Scenario: Will add 2 banana amounts
10. Steps - Gherkins
# features/BananaCalculator.features
# Describe the steps
Given I have 3 Bananas
When I add 5 Bananas
Then I should have 8 Banana
11. Example
Feature: Banana Calculator
As Bob the Banana merchant,
I want a calculator that can add the amount of bananas
so that I can know how many bananas I currently have
Scenario: Will add 2 banana amounts
Given I have 3 Bananas
When I add 5 Bananas
Then I should have 8 Banana
20. Mink
In order to test, that our web application behaves correctly, we need a way to simulate this
interaction between browser and web application in our tests
Mink is an open source acceptance test framework for web applications
23. Selenium
○
JS Support
○
Can run multiple browser
○
Need to start Selenium RC
○
Not Headless
○
Need to load Drivers for different browsers
○
Doesn’t play nice at times
java -jar selenium-serverstandalone.jar
java -jar selenium-serverstandalone.jar Dwebdriver.chrome.driver=
"/usr/local/bin/chromedriver"
24. Sahi
○
JS Support (kinda)
○
Can run Multiple browsers
○
Need to setup localhost proxy
in browser
○
Not headless
○
Issues with Ajax Request
29. When i fill in 'input.flooble-widgets[:first]' with 'FooBar'
○
Write BDD in the domain language
○
You should never see any DOM elements
30. Anti-pattern
When I subscribe to the newsletter
rather than
And I set the value of 'input#newsletter-signup-checkbox' to '1'
and
When I search for articles containing the words 'rockets'
rather than
When I fill in 'input#search-terms' with 'rockets'
And I click 'button#search-button'
31. And I wait 10 seconds
○
This is not a requirement
○
Roll up the execution into the page element
32. Try this
public function search($keywords)
{
$searchForm = $this->find('css', 'form#search');
if (!$searchForm) {
throw new ElementNotFoundException($this->getSession(), 'form', 'css', 'form#search');
}
$searchForm->fillField('q', $keywords);
$searchForm->pressButton('Google Search');
return $this->getPage('Search results');
}