2. INTRODUCTION
• Behavior Driven Development & Acceptance Test Driven Development
• Building the Right Code
• Test Driven Development
• Building the Code Right
3. ACCEPTANCE TEST DRIVEN DEVELOPMENT
• What
• Process for defining automated acceptance tests early in the development process
• Why
• Ensure that all project members understand precisely what needs to be done and
implemented
• How
• Tools: Specflow (.NET), Jasmine (JavaScript), Cucumber (Ruby), Fitnesse+FitSharp
4.
5. BEHAVIOR-DRIVEN DEVELOPMENT
• What
• Framework for defining automated acceptance tests to assert whether the system
does what it is supposed to do (is the expected functionality implemented?)
Given [condition], when [action], then [expectation]
• Why
• Provides guidance on organizing the conversation between developers, testers and
domain experts
6.
7. SPECFLOW
• Tester, business analyst and developer discuss requirements and write feature with
Given [ ], When [ ], Then [ ] specification
• Developer writes step definitions (glue code) that act on the target system
• Tests are executed similar to unit tests
9. CASE MOVIE TICKETING SYSTEM
• Stories
• As an employee, I want to add groups of visitors so that ticket prices can be
calculated
• As an employee, I want to calculate total ticket prices for groups so that I can charge
the customer
• Ticket prices
Adult Children
€ 8,-- €5,--
10. TEST DRIVEN DEVELOPMENT
• What
• Writing automated tests to test whether code works correctly
• Why
• Improves code quality
• Automated regression tests support refactoring
• How
• TDD Cycle:
• a) Write executable, failing test
• b) Write minimum amount of code to make the test pass
• c) Refactor
ATDD is a practice that emphasizes the importance of open communication and feedback within the teamIt focuses on progressively driving value out of the system, demonstrating how that value is delivered via automated acceptance criteria
Given I have entered the following personsAnd the adult price is <AdultPrice> and the price for children is <ChildrenPrice>When I press calculateThen the total tick price should be <TotalPrice>
Begun in 1999, introduced with XPWie heeft er weleens een unit test geschreven?Wie schrijft regelmatig unit testen in zijn huidige projectWie practiseert TDD (unit test voor implementatie schrijven)?Je bent een deskundige ontwikkelaar, je maakt weinig fouten en de klant is tevreden. Waarom zou je dan extra moeite nemen om extra code voor unit testen te gaan schrijven?Leidt tot beter design (dependencyinjection, single responsibility SOLID (wanneer je objecten eenvoudig te unit testen zijn zonder veel afhankelijkheden te moeten mocken/declareren) is je testdoelobject mooi geisoleerd denk aan Program klasse unit tests vergeleken met modelagent unit tests. Toon Program klasse en ProgramAgent klasse en laat zien dat er geen unit tests nodig zijn voor ProgramAgent)80% van de kosten gaan in onderhoud zitten. Met unit testen is de code beter aanpasbaar, voor jou maar helemaal voor toekomstige ontwikkelaars.Kwaliteit neemt toe, ook de edge cases kun je makkelijk testenRegressietestenondersteuning voor refactoringbest practiceswanneerereen defect wordtgevonden door een tester of gebruiker, schrijfdaneen unit test om het scenario tereproducerenfailing test, succeeding test, refactoralleenpubliekemethodentesten, consider moving the method to a separate classpitfalls* mock alleenklassen met eenafhankelijkheidnaareenexterne resource zoals repositories, file loaders, service agents. Nietklasses met logicazoals Calculators
var result = 10/Math.Floor(0.5);mighty moosefluent assertionsmoq / nsubstitute /rhinomock / microsoft fakes ultimate question of life