shallow depth of tests scallable bdd and tdd
DESCRIPTION
http://fabiopereira.me/blog/2012/02/05/speaking-at-qcon-beijing/QCon Beijing presentation.Shallow Depth of Tests - Scalable TDD/BDDTest automation is prevalent in the software development community. Practices like TDD and BDD are widespread and applied almost unquestionably. However, several organisations have struggled in attempting to scale automated test suites, which very often become slow, brittle, non-deterministic, unreliable and difficult to maintain.In this talk, I will discuss some common mistakes, Tautological TDD (TTDD), for example, and also present patterns that I have successfully applied, such as Shallow Depth of Tests and Testing Pyramid. These have enabled us to achieve maintainable and scalable tests that fulfill their purpose - to help software development teams deliver faster and more confidently the features required by business people.TRANSCRIPT
Shallow Depth of Test Scalable TDD/BDD
www.fabiopereira.me
TDD Call Centre
• Slow • Brittle • Non-deterministic • Difficult to maintain • They do not scale
No Tests
TODAY
???????
TDD Evolution
Quote System
29 year old man wants: - Car insurance - Travel insurance
Car $25 Travel $15
Quote System
62 year old man wants: - Car insurance - Travel insurance
Car $25 Travel (Too Old)
Quote System
Can sell car insurance to people between 18 and 65. Can sell travel insurance to people between 18 and 60
Travel 17 L 18 J 60 J 61 L
Car 17 L 18 J 60 J 61 J 65 J 66 L
Internet
Quote System
Controller Domain Model
JavaScript
Repository
WebServer ReverseProxies Authentication
JSON Services
Controller Quote Pricing Validator Mandatory
Validator
BusRule Validator
BR1 BR2 BRN …
Domain Model
Validations
Price Calculator
Cover1 Cover2 …
PRICING DATA
Pricer Error Handler
Repository
JSON
Controller Quote Pricing Validator Mandatory
Validator
BusRule Validator
BR1 BR2 BRN …
Domain Model
Validations
Price Calculator
Cover1 Cover2 …
PRICING DATA
Pricer Error Handler
Repository
JSON
Age Restriction Rule
Controller Quote Pricing Validator Mandatory
Validator
BusRule Validator
BR1 BR2 BRN …
Domain Model
Validations
Price Calculator
Cover1 Cover2 …
PRICING DATA
Pricer Error Handler
Repository
JSON
h#p://blogs.agilefaqs.com/
Most so6ware organiza;ons today suffer from what I called the “Inverted Tes+ng Pyramid” (…)
h#p://jamescrisp.org
h#p://clipboarded.blogspot.com
Controller Quote Pricing Validator Mandatory
Validator
BusRule Validator
BR1 BR2 BRN …
Domain Model
Validations
Price Calculator
Cover1 Cover2 …
PRICING DATA
Pricer Error Handler
Repository
JSON
Age Restriction Rule
Shallow Depth of Test
Shallow Depth of Test
MyTest
Mock/Stub
Stimulate
Operate
Simulate
Controller Quote Pricing Validator Mandatory
Validator
BusRule Validator
BR1 BR2 BRN …
Domain Model
Validations
Price Calculator
Cover1 Cover2 …
PRICING DATA
Pricer Error Handler
Repository
JSON
www.fabiopereira.me
Business Devs Broker Renewal Risk
Address Insurer
user Edit
UBD_CD TB_ADR en:ty
BDD
Given When Then
B D D
BDD at the Unit Level
Use Builders and Fixtures
h#p://en.wikipedia.org/wiki/Builder_pa#ern
BDD
Concept
Tools/ Current Practices
h#p://blog.carbonfive.com/2011/11/07/modern-‐cucumber-‐and-‐rails-‐no-‐more-‐training-‐wheels/
web_steps.rb
Simulate Http
Wiring
IN MEMORY DB (HSQL)
You can test Spring Config
High level and Test Journeys at the UI Level
An authenticated insurance advisershould be able to sell insurance to a customer who fulfills all mandatory requirementsBusiness rules should be applied toall customers who attempt to buy insuranceCustomers should be given the right insurance premium based on their insurance requirements
High level and Test Journeys at the UI Level
An authenticated insurance adviser, should be able to sell insurance to a customer who fulfills all mandatory requirementsBusiness rules should be applied toall customers who attempt to buy insuranceCustomers should be given the right insurance premium based on their insurance requirements
High level and Test Journeys at the UI Level
An authenticated insurance adviser, should be able to sell insurance to a customer who fulfills all mandatory requirementsBusiness rules should be applied toall customers who attempt to buy insuranceCustomers should be given the right insurance premium based on their insurance requirements
TTDD – Tautological TDD
Tauto… WHAT?!
Tautology: from Greek: tauto: the same logos: word/idea Tautological: -‐ needless, redundant repe;;on of an idea -‐ repe;;on of same sense in different words; -‐ the phrase ”a beginner who has just started” is tautological
T A U T O L O G I C A L
TTDD – Mocks
Setup Mocks
Call a method/function
Assert that mocks were called
(Dependency Injection Code)
(Mocks Setup)
No Tests
Slow, brittle, etc
Shallow DoT Test Pyramid Unit BDD UI Journeys Stop TTDD
Let’s evolve…
www.fabiopereira.me
References h#p://apcj.blogspot.com/2005_04_01_archive.html h#p://wa;rmelon.com h#p://jamescrisp.org h#p://clipboarded.blogspot.com h#p://anton.kovalyov.net/2011/02/20/why-‐i-‐forked-‐jslint-‐to-‐jshint/ h#p://en.wikipedia.org/wiki/Builder_pa#ern h#p://jawr.java.net/ h#p://pivotal.github.com/jasmine/ h#p://code.google.com/p/js-‐test-‐driver/ h#p://blogs.agilefaqs.com/ h#p://fabiopereira.me/blog/2012/03/18/introducing-‐depth-‐of-‐test-‐dot/
Images h#p://www.flickr.com/photos/nburrows h#p://www.luxury-‐insider.com/uploads/news/2010/06/korean-‐air-‐first-‐class-‐award-‐1.jpg h#p://one7.files.wordpress.com/2010/06/browsers.jpg h#p://www.luxury-‐insider.com/uploads/news/2010/06/korean-‐air-‐first-‐class-‐award-‐1.jpg h#p://www.digital-‐photography-‐student.com/wp-‐content/uploads/2009/01/DOF-‐Shallow-‐Deep.png h#p://www.flickr.com/photos/bullgod/2604300680/ h#p://www.whatsgo#ago.com/wp-‐content/uploads/2007/12/angry_phone2.jpg
Thanks
www.fabiopereira.me