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
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Optimizing for Happiness
mojombo
376
70k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Automating Front-end Workflow
addyosmani
1366
200k
Done Done
chrislema
181
16k
Building Applications with DynamoDB
mza
91
6.1k
A designer walks into a library…
pauljervisheath
204
24k
Designing for Performance
lara
604
68k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Bash Introduction
62gerente
608
210k
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