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
100
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
290
Qualitative Analysis of Algorithms
mattyoho
5
410
Metaprogramming Ruby
mattyoho
19
670
Exploiting The Resource Idiom
mattyoho
2
380
shared_auth.pdf
mattyoho
0
2.3k
background job patterns
mattyoho
2
490
Request-Response cycle
mattyoho
5
180
Intro to Rest
mattyoho
6
570
Featured
See All Featured
Statistics for Hackers
jakevdp
793
220k
Music & Morning Musume
bryan
46
6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
28
2.2k
Web development in the modern age
philhawksworth
204
10k
Adopting Sorbet at Scale
ufuk
72
8.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
23
590
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
34
1.9k
Rebuilding a faster, lazier Slack
samanthasiow
78
8.5k
The Cult of Friendly URLs
andyhume
76
5.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
263
13k
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
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