34
Shallow Depth of Test Test at the appropriate level and achieve a testing pyramid www.fabiopereira.me

Shallow Depth of Test - Test at the appropriate level

Embed Size (px)

DESCRIPTION

Presentation given at ThoughtWorks XConf2011.

Citation preview

Page 1: Shallow Depth of Test - Test at the appropriate level

Shallow Depth of Test

Test at the appropriate level and achieve a testing pyramid  

www.fabiopereira.me  

Page 2: Shallow Depth of Test - Test at the appropriate level

Quote System  

Male 29y 100K wants IP 5K and Life 500K

IP $25 Life $15

Page 3: Shallow Depth of Test - Test at the appropriate level

Quote System  

Male 62y 100K wants IP 5K and Life 500K

IP $25 Life error

Page 4: Shallow Depth of Test - Test at the appropriate level

Quote System  

Can sell life cover to people between 18 and 60. Can sell IP cover to people between 18 and 65

Life 18 J 17 L 60 J 61 L

IP 18 J 17 L 60 J 61 J 65 J 66 L

Page 5: Shallow Depth of Test - Test at the appropriate level

Internet

Quote System  

Page 6: Shallow Depth of Test - Test at the appropriate level

Controller  Domain Model  

JavaScript  

Repository  

WebServer ReverseProxies Authentication

JSON Services  

Page 7: Shallow Depth of Test - Test at the appropriate level

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

Page 8: Shallow Depth of Test - Test at the appropriate level

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

Page 9: Shallow Depth of Test - Test at the appropriate level

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

Page 10: Shallow Depth of Test - Test at the appropriate level

h#p://blogs.agilefaqs.com/  

Page 11: Shallow Depth of Test - Test at the appropriate level

h#p://jamescrisp.org  

Page 12: Shallow Depth of Test - Test at the appropriate level

h#p://clipboarded.blogspot.com  

Page 13: Shallow Depth of Test - Test at the appropriate level

h#p://wa9rmelon.com  

Page 14: Shallow Depth of Test - Test at the appropriate level

www.fabiopereira.me  

Page 15: Shallow Depth of Test - Test at the appropriate level

BDD at the Unit Level  

Page 16: Shallow Depth of Test - Test at the appropriate level

Use builders and Fixtures  

h#p://en.wikipedia.org/wiki/Builder_pa#ern  

Page 17: Shallow Depth of Test - Test at the appropriate level
Page 18: Shallow Depth of Test - Test at the appropriate level
Page 19: Shallow Depth of Test - Test at the appropriate level

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

Page 20: Shallow Depth of Test - Test at the appropriate level

Shallow Depth of Test  

Page 21: Shallow Depth of Test - Test at the appropriate level
Page 22: Shallow Depth of Test - Test at the appropriate level

Stimulate

Operate  

Simulate  

MyTest  

Mock/Stub  

Page 23: Shallow Depth of Test - Test at the appropriate level

Stimulate

Operate  

Simulate  

MyTest  

Mock/Stub  

Page 24: Shallow Depth of Test - Test at the appropriate level

Simulate  

Page 25: Shallow Depth of Test - Test at the appropriate level

Easy to Stub  

And… Mock  

Simulate Http  

Page 26: Shallow Depth of Test - Test at the appropriate level

Wiring

Page 27: Shallow Depth of Test - Test at the appropriate level

You can test Spring Config  

Page 28: Shallow Depth of Test - Test at the appropriate level

IN MEMORY DB (HSQL)

Page 29: Shallow Depth of Test - Test at the appropriate level

High level and Test Journeys at the UI Level  

Page 30: Shallow Depth of Test - Test at the appropriate level

High level and Test Journeys at the UI Level  

Page 31: Shallow Depth of Test - Test at the appropriate level

h#p://blog.carbonfive.com/2011/11/07/modern-­‐cucumber-­‐and-­‐rails-­‐no-­‐more-­‐training-­‐wheels/  

Page 32: Shallow Depth of Test - Test at the appropriate level

www.fabiopereira.me  

Page 33: Shallow Depth of Test - Test at the appropriate level

Questions  

Answers  

Comments  

www.fabiopereira.me  

Page 34: Shallow Depth of Test - Test at the appropriate level

References h#p://apcj.blogspot.com/2005_04_01_archive.html  h#p://wa9rmelon.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/  

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/  

Thanks  

www.fabiopereira.me