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
Randomness in Testing - Paul Grayson
Search
Las Vegas Ruby Group
September 25, 2013
0
54
Randomness in Testing - Paul Grayson
Las Vegas Ruby Group
September 25, 2013
Tweet
Share
More Decks by Las Vegas Ruby Group
See All by Las Vegas Ruby Group
Ruby ISO Standard - David Grayson
lvrug
0
130
Windows Automation - Howard Feldman
lvrug
0
68
Separating Your Application from Rails - Brian Hughes
lvrug
0
120
SWIG and Ruby - David Grayson
lvrug
0
76
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
130
The Hamster Gem - Ryan Mulligan
lvrug
1
90
Varnish+Redis - Russ Smith
lvrug
1
100
Lambdas and Pops - Jan Hettich
lvrug
0
79
Making Good Use of Fonts - Russ Smith
lvrug
1
88
Featured
See All Featured
Statistics for Hackers
jakevdp
799
220k
Rails Girls Zürich Keynote
gr2m
95
14k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Designing for humans not robots
tammielis
254
26k
The Invisible Side of Design
smashingmag
302
51k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
630
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
BBQ
matthewcrist
89
9.8k
Transcript
Randomness in Testing Paul Grayson 2013-09-25
Normal testing: try edge cases • Easy when you have
a geometric picture:
“Fuzz testing” for difficult edges • What are the “edge
cases” here?
Fuzz testing kata example
Note: fuzz tests generally more simple-minded Things to Fuzz test
for: • exceptions or other bad behavior • outputs consistent with inputs • exact answer for a simplified domain (hard!)
Fuzz Testing: NOT part of RSpec • Just use rand
in your tests.
Test order dependence • Ideal: tests are independent • DO
NOT use objects created out of the context • DO NOT break when other objects exist
Test order kata example
When a test fails... • Write a test that always
fails, or fix the tests • Re-use the seed to debug rspec --seed 1234
Using RSpec seed with rand srand RSpec.configuration.seed + 1
Putting it together • Automatically re-use the seed
Other random examples • Code mutation • Unavoidable randomness (network,
threads) • Testing random code