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
Speed Design
sergeychernyshev
24
610
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Ruby is Unlike a Banana
tanoku
96
11k
Building Your Own Lightsaber
phodgson
103
6.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
KATA
mclloyd
29
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
830
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