4. Dirty Hacking
‣ No documentation
‣ No testing
‣ No clue if it still working
‣ Maintenance doesn’t really matter
‣ Code changes are a lottery
‣ Easy refactoring impossible
Slide 4
TEQneers GmbH & Co. KG www.teqneers.de
6. Automated Testing
✓Verify code or results
✓Can be automated
✓Code first, add tests later
‣ Time gap between development and testing
‣ Test not based on original requirements
‣ Tests influenced by code
Slide 6
TEQneers GmbH & Co. KG www.teqneers.de
8. Test-Driven Development
✓Tests follow your original requirements
✓Code is an easy solution to the problem
✓Tests for all code
Slide 8
TEQneers GmbH & Co. KG www.teqneers.de
9. Test-Driven Development
‣ Write tests first, add code later
‣ Feels unnatural
‣ Tests written by developers
‣ Potential for over-design
‣ Customer unable to participate
Slide 9
TEQneers GmbH & Co. KG www.teqneers.de
16. Take all items
add them up
multiply by VAT
total should be sum + VAT
Customer Developer Tester
Slide 14
TEQneers GmbH & Co. KG www.teqneers.de
17. Translation
Slide 15
TEQneers GmbH & Co. KG www.teqneers.de
18. Translation
Slide 16
TEQneers GmbH & Co. KG www.teqneers.de
19. Goal
‣ Common language
‣ Tester writing tests
‣ Customer writing specs
‣ Common dictionary
‣ Specs == Tests
Slide 17
TEQneers GmbH & Co. KG www.teqneers.de
20. Behavior-Driven Development
‣ Writing tests first in a customer friendly language
‣ Your tests are your specifications and your
specifications are your tests
‣ Dan North: “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.”
Slide 18
TEQneers GmbH & Co. KG www.teqneers.de
21. Gherkin
‣ Feature: Generating an invoice
‣ Scenario: Calculating gross total in Germany
‣ Given the customer is from Germany
‣ And the net total is 100 EUR
‣ When I calculate the gross total
‣ Then the final invoice total should be 119 EUR
Slide 19
TEQneers GmbH & Co. KG www.teqneers.de
24. What’s testable in Behat?
‣ Business Intelligence/Models
‣ API’s
‣ Web Pages
‣ Single Scripts
‣ Server-Server-Interaction
Slide 22
TEQneers GmbH & Co. KG www.teqneers.de
25. How does it work?
Slide 23
TEQneers GmbH & Co. KG www.teqneers.de
26. What BDD is NOT
‣ No replacement for TDD
‣ Not a “real” spoken language
‣ Not a drop in solution
‣ Common language needs to be developed
‣ Developer still has to write glue code
‣ It’s not magic!
Slide 24
TEQneers GmbH & Co. KG www.teqneers.de
27. Good Practice
‣ Get everyone on board
‣ Define common language and syntax
‣ Define test scope
‣ Build project specific testing environment
‣ Don’t expect perfect solution from start
‣ Don’t make it too complicated
Slide 25
TEQneers GmbH & Co. KG www.teqneers.de
28. Questions?
Slide 26
TEQneers GmbH & Co. KG www.teqneers.de
29. Thanks for listening
contact us if you have any questions
email: oliver@php.net
email: stefan@teqneers.de
Have Fun!
Slide 27
TEQneers GmbH & Co. KG www.teqneers.de
Notas do Editor
\n
\n
\n
\n
\n
\n
\n
No extra code, not needed\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
http://dannorth.net/whats-in-a-story/\n
\n
\n
\n
\n
\n
extension to TDD\nNatural language=more dynamic syntax (e.g. plural)\n\n
Syntax: I -> We, Uppercase, Tense, ...\nTest scope: API, GUI, Backend only, ...\nEnvironment: DB restore strategies, ...\nToo complicated = tests have to be tested\n