Presented at CVREG on 3/13/2012.
http://www.cvreg.org/2012/3/7/march-meeting-m-scott-ford-and-train-to-test
Abstract
Many pundits would have you believe that the switch from a developer to a developer tester is just a bit that you can flip in your head. I claim that this is false.
While testing is something we all know that we should be doing more of, many of us are struggling to figure out how. Chances are you’re somewhere in between a developer that never tests and one that tests every time s/he should. And I bet that you’re unhappy with where you are at, and you’d like to figure out how to get closer to where you want to be.
Using the metaphor of going to the gym, I’ll go over some exercises that you can perform. Some of these exercises you’ll be able to perform on your current projects, while others you may want to try out on a toy or side project first. These should help you feel better about how often you test, and it might be easier than losing a few pounds.
4. PROJECTS
Library automation Law enforcement
Experimental aircraft Public API for email hosting
Library self checkout More law enforcement
Real property management Content management
Railroad traffic control E-Commerce
Back office automation
5. MISSION CRITICAL AND
SAFETY CRITICAL
Safety critical:
a software failure may result in the loss of someone’s life
Mission critical:
a software failure may result in the loss of someone’s money
9. TESTING AND EXERCISE
HAVE A LOT IN COMMON
Getting started is intimidating
Improves health
Developing the habit is hard
Work now prevents problems
later
There’s always room for
improvement
16. LET’S TALK ABOUT MEASUREMENTS
Test Coverage Body Mass Index
TC = Tested LOC / LOC BMI = mass / height2
Size of your project dictates Your age dictates what’s
what’s reasonable reasonable
Too much energy on test It’s possible to go to the gym
coverage is not productive too much
17. WHAT GOAL SHOULD I SET
SMART goals are best
Specific Measurable Attainable Reasonable and Timely.
Example:
By January 2013 test coverage will have increased by 5 percentage
points to 12%.
Source: http://en.wikipedia.org/wiki/SMART_criteria
21. RUN RSPEC
$ rspec
.
Finished in 0.00043 seconds
1 example, 0 failures
Coverage report generated for RSpec to ./coverage.
2 / 3 LOC (66.67%) covered.
23. WRITE MORE TESTS
Anytime you find yourself asking these questions, consider writing a
test
What happens when I pass nil to this method?
How does this method respond if a dependent method raises an
exception?
Do those 30 lines that I wrote actually work? (How about the 30 I
haven’t written yet?)
24. THIS IS A PERFECTLY VALID TEST
describe Demo do
it ‘should not crashed when created with nil’
Demo.new(nil)
end
end
25. PRACTICE NOT USING THE DEBUGGER
When you start a debugging session you have a question that you’re
trying to answer.
Consider whether or not it’s possible to formalize that question in a
test.
If you find yourself repeating the debugging session more than twice,
then find a way to formalize the question.
27. THINGS TO KEEP IN MIND
It’s okay that you’re struggling. There are others out there like
you.
It’s okay that you’re not testing
every single line of code. You are not alone.
It’s okay that you want to give Sticking with it is hard, but
up. worthwhile.
It’s okay that you feel guilty
about not testing enough.
28. PHOTO CREDITS
All photos are licensed under a Created Commons “Apples & Oranges - They Don’t Compare” by
license that requires attribution. In order of appearance: TheBusyBrain
http://www.flickr.com/photos/thebusybrain/2492945625/
“Brompton World Championship - Sprint Finish” by Jon
Spooner “out with the old, in with the new” by KetuGajjar
http://www.flickr.com/photos/johnspooner/2899977876/ http://www.flickr.com/photos/ketugajjar/5406134368/
“Young & Old, Let’s Get it On” by AlphaTangoBravo / “FOCUS on the GOAL !” by GHOURI !
Adam Baker http://www.flickr.com/photos/geekydevil/2707101111/
http://www.flickr.com/photos/atbaker/447122802/ “scale_zero” by dsearls
“Sailor participates in Marine Corps Combat Fitness http://www.flickr.com/photos/docsearls/5500725788/
Test.” by Official U.S. Navy Imagery “New Year’s Resolution: 36/365” by SashaW
http://www.flickr.com/photos/usnavy/5590118536/ http://www.flickr.com/photos/sashawolff/3171917389/
“Danbo Goes to the Gym” by chauromano “Focus” by toolstop
http://www.flickr.com/photos/chauromano/5786885286/ http://www.flickr.com/photos/toolstop/4546017269/
29. CONTACT INFO
Senior Developer with Rails Dog, LLC
Chief Code Monkey with Corgibytes, LLC
mscottford.com
github.com/mscottford
@mscottford
scott@mscottford.com