Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
testing revisited - outside-in
Search
Matt Yoho
June 21, 2012
1
110
testing revisited - outside-in
Matt Yoho
June 21, 2012
Tweet
Share
More Decks by Matt Yoho
See All by Matt Yoho
Working with Git and GitHub
mattyoho
4
300
Qualitative Analysis of Algorithms
mattyoho
5
410
Metaprogramming Ruby
mattyoho
19
670
Exploiting The Resource Idiom
mattyoho
2
390
shared_auth.pdf
mattyoho
0
2.3k
background job patterns
mattyoho
2
490
Request-Response cycle
mattyoho
5
180
Intro to Rest
mattyoho
6
580
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
244
12k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
GraphQLとの向き合い方2022年版
quramy
44
14k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
4
380
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Being A Developer After 40
akosma
89
590k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
Statistics for Hackers
jakevdp
797
220k
RailsConf 2023
tenderlove
29
1k
Transcript
Testing Revisited: Driving Implementation with Outside-in Specs Thursday, June 21,
12
Testing isn’t about verification, per se Thursday, June 21, 12
It’s a design tool Thursday, June 21, 12
An outline Thursday, June 21, 12
Executable system specification Thursday, June 21, 12
Red Green Refactor Thursday, June 21, 12
1) Write a spec Thursday, June 21, 12
1) Write a spec See it fail Thursday, June 21,
12
2) Write enough code to make it pass Thursday, June
21, 12
2) Write enough code to make it pass Make it
green Thursday, June 21, 12
3) Refactor the implementation and/or specs Thursday, June 21, 12
3) Refactor the implementation and/or specs Clean the code, reduce
duplication Thursday, June 21, 12
http://jakegoulding.com/blog/2011/10/10/learned-about-testing-last-year/ Thursday, June 21, 12
1) Write an acceptance test Thursday, June 21, 12
1a) Write a spec Thursday, June 21, 12
1b) Write enough code to make it pass Thursday, June
21, 12
1c) Refactor the implementation and/or specs Thursday, June 21, 12
2) Write enough unit tests and code to pass the
acceptance test Thursday, June 21, 12
3) Refactor Thursday, June 21, 12
4) Repeat Thursday, June 21, 12
Sometimes, we want to isolate the item under test from
another dependency Thursday, June 21, 12
A dependency is any external piece of code the item
under test relies on or collaborates with Thursday, June 21, 12
When a dependency is expensive or difficult to use, it
may be a good idea to swap it out for a test double Thursday, June 21, 12
Test doubles: stubs and mocks Thursday, June 21, 12
stub: a “dumb” stand-in for a real object that responds
to messages (methods), sometimes returning canned responses Thursday, June 21, 12
Used when we want to isolate the code under test
from uncertainty or costly execution Thursday, June 21, 12
mock: a stand-in for a real object that expects to
receive messages (methods) and provides testing verification Thursday, June 21, 12
Used when we want to test (verify) that the code
under test collaborates properly with its depedencies Thursday, June 21, 12
Random thoughts Thursday, June 21, 12
Testing is hard - especially BDD/TDD Thursday, June 21, 12
Well, it’s easy. It’s just subtle. Thursday, June 21, 12
Practice, practice, practice. Thursday, June 21, 12
People do it “wrong”. Often. Thursday, June 21, 12
They will think they’re doing it right. Or at least,
doing it less wrong than they are. Thursday, June 21, 12
Testing is a religion - especially TDD/BDD Thursday, June 21,
12
Testing is a religion - especially TDD/BDD People will evangelize.
Thursday, June 21, 12
Testing is a religion - especially TDD/BDD People will evangelize.
And they’re wrong. Thursday, June 21, 12
Read. Learn. Practice, practice, practice. Thursday, June 21, 12
Example: Add refeeds to simple_feed Include “refeeded” count Thursday, June
21, 12
Exercise: Add show/hide item to simple_feed Add a link on
items the user owns to hide them, or to show them for hidden items. Thursday, June 21, 12