This document discusses behavior-driven development (BDD) and how the presenters use it. BDD focuses on writing tests in natural language to describe features from the customer's perspective before writing code. The presenters use tools like Behat and Gherkin to write automated tests in plain language, focusing on collaboration and ensuring development matches business needs. They provide tips on using multiple contexts, page objects, and screenshots in BDD. Alternatives like PhpSpec are also mentioned.
5. •To do the presentation
W E WA N T T O
•And to know you
6. T E S T I N G
• TESTS REDUCE BUGS
• TESTS ARE GOOD DOCUMENTATION
• TESTS ALLOW SAFE REFACTORING
TESTS
• REDUCE THE COST OF CHANGE
• TESTING FORCES YOU TO THINK
7. A G I L E T E S T I N G Q U A D R A N T
Q1
Q2 Q3
Q4
8. B D D
BDD (Behaviour Driven Development) is a
synthesis and refinement of practices stemming
from TDD (Test Driven Development) and ATDD
(Acceptance Test Driven Development).
9. B D D P R O S
• Driven by bussiness value (outside-in)
• Requirements and tests are in natural
language
• Adds structrure to TDD
• Collaboration between team members
10. BDD WORKFLOW
• Think and describe a feature
• Red, green, yellow
• Write a failing test
• Write a small amount of production code
• Refactor
• Write a Unit tests along the way
19. S C H E M A
Foxrate
Application
Foxrate API Foxrate AKZ Plugins
Builds SDK
Tests SDK
Builds Modules
(FI)Runs tests
Deploys to markets
20.
21. B E H A T
Behat is an open source behavior-driven
development framework for PHP 5.3 and 5.4.
What is behavior-driven development, you ask?
It’s the idea that you start by writing human-
readable sentences that describe a feature of your
application and how it should work, and only then
implement this behavior in software.
22. We are not testing that application functions as we
(developers) expect it to, but instead we’re testing
that it fullfils clients business needs.
Behat by example by Konstantin Kudryashov
23. You might think about Behat as a tool to
teach your clients about testing, but in reality
it's a tool to teach you about client
business.
24. B E H AT I N S TA L AT I O N
"require-dev": {
"behat/behat": "3.*@stable",
"behat/mink-extension": "*”,
"behat/mink": "1.5@stable",
"behat/mink-selenium2-driver": "*",
"behat/common-contexts": "*@dev",
"phpunit/phpunit": "4.*@stable",
"sensiolabs/behat-page-object-extension":
"dev-master",
"ocramius/proxy-manager": "~0.5"
}
composer update
bin/behat --init
25. B E H A T E X A M P L E
• Gherkin
Narrative
Scenario
Scenario
details
26. B E H A T E X A M P L E
• Gherkin
Events
Context
Outcome
Benefit
Role
Feature
28. BEHAT 3: WHAT’S NEW?
• Implements SnippetAcceptingContext
• Turnip mathching (@Given My name is
:name). Regex is still supported.
• Output in code
• Cleaner and more structured output (shows
exactly wher it failed)
• Error out levels
30. U S E M U LT I P L E C O N T E X T S
public function __construct(array $parameters)
{
$this->useContext('subcontext_alias', new AnotherContext());
}
36. Behat deals to have specifications that
reflects the environment from the
outside.
PHPSpec responds to the behaviour in
the lower level, from the internal of
the classes.
PHPSpec is considered a tool that
helps you to develop.
InternalExternal
B E H A T V S P H P S P E C
Prasome supratingumo - daugelis is musu viesuose pristatymuose zengiame pirmuosius zingsnius
Kas rasote testus
Kas naudojate TDD
Kas rasote web acceptance testus?
Kas naudojate BDD
----- Meeting Notes (08/12/14 15:08) -----
Kas yra Behat?
Black Box White Box Unit Integration Functional System Regression Performance Smoke Canary Usability A/B Characterization tests
...
A study conducted by Microsoft and IBM showed that writing tests can add 15% – 35% to development time but reduce the number of bugs by 40% – 90%
Q2Q3 Validate
Q4 Verify
Q2q1 For the team
Q3Q4 For the Customer
Ility - Usability, Maintainability, Scalability, Availability, Extensibility, Security, Portability,
----- Meeting Notes (08/12/14 15:13) -----
Virsuje orientuoti i verslo logika
TDD is exclusive to programmer domain
We
B – tai elgsena
BDD - Agile technika, apjungianti ir patobulinanti TDD ir web acceptance testavimo technikas, , skatinanti bendradarbiavimą tarp techninių ir ne techninių darbuotojų.
Orientuota I nauda verslui ir vartotojo elgsena
Visi reikalavimai rašomi žmonių kalba
Suteikia TDD testams struktūrą
skatina tikslęsnį užduoties formulavimą įprasta žmogui kalba
Skatina supratimą tarp visų organizacijos dalyvių
Panaudojant BDD, galime naudoti irankius, su kuriais visas formuluotes galime testuoti automatizuotai
----- Meeting Notes (08/12/14 00:01) -----
Grafiškai pavaizduota sekančioje skaidrėje
Rašykite nesikartojančius testus
Kaip sakė K. Kudriasiov, Behat kūrėjas, viename šviežiame podcaste - jūsų tikslas yra testuoti pačius svarbiausius dalykus.
----- Meeting Notes (08/12/14 15:52) -----
Dabar noreciau pereiti prie esminiu BDD daliu
----- Meeting Notes (08/12/14 15:52) -----
Apie technine BDD puse as papasakosiu per savo komandos irankiu pristatyma
Dabar ape du teorinius BDD elementus: istorija ir roles
Jau tukstancius metu zmones pasakoja istorijas.
Su istorija jus uztikrinate, kad jusu ir jusu kliento biznio logikos suratimas yra vienodas
And even leveling up client knowledge of his business
In many many cases,
----- Meeting Notes (08/12/14 15:52) -----
Su istorija jus uztikrinate, kad jusu ir jusu kliento biznio logikos suratimas yra vienodas
Feature: registration
in order to maintain my shopping history
as a site visitor
I need to be able to register on this site
----- Meeting Notes (08/12/14 15:52) -----
Kokiu tikslu arba kodel?
Ka
kaip?
Ryan Weaver
I think the real difference betw”een mid-level and pro-level Behat usersis the understanding of roles andtheir place in features.
----- Meeting Notes (08/12/14 15:52) -----
Nurodydami role, jus patikslinate, kam si role skirta
Feature: registration
in order to maintain my shopping history
as a site visitor
I need to be able to register on this site
Behaviour-driven development is an “outside-in” methodology. It starts at the outside by identifying business outcomes, and then drills down into the feature set that will achieve those outcomes
Behaviour-driven development (BDD) takes the position that you can turn an idea for a requirement into implemented, tested, production-ready code simply and effectively, as long as the requirement is specific enough that everyone knows what’s going on
Kas as
Problemos
Vizualinis patikirinimas
Trumpas Foxrate pristatymas: tai atsiliepimu, ivertini
Behat testavimas : Docker / CI / Naujos formos / Moduliai
Problemos
Component based Engineering vs Legacy
----- Meeting Notes (05/12/14 16:03) -----
Isimtiniais atvejais naudojame BDD
uztikrina, kad testuojame butent tai, ko labiausiai reikia kliento verslui
padeda JUMS geriau suprasti kliento versla
As user? In many cases it’s a visitor!
Behat
Acceptance testing
Test a feature by executing scenarios
Mink – controls browser
Web acceptance testing
the context class is all about how to test your application, and that it actually behaves as expected
Mix Contexts!
neverta sitos
Add screenshots
Is esmes K. Kudriashov patarimas butu naudoti atskira konteksta atskiroms rolems.
Paslepia visas slikstynes ir leidzia jums bendrauti graziu ir lengvai skaitomu kodu.
----- Meeting Notes (05/12/14 16:03) -----
gal ismesiu