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
38
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
92
Windows Automation - Howard Feldman
lvrug
0
37
Separating Your Application from Rails - Brian Hughes
lvrug
0
70
SWIG and Ruby - David Grayson
lvrug
0
39
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
96
The Hamster Gem - Ryan Mulligan
lvrug
1
70
Varnish+Redis - Russ Smith
lvrug
1
73
Lambdas and Pops - Jan Hettich
lvrug
0
38
Making Good Use of Fonts - Russ Smith
lvrug
1
53
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
6
1.5k
Faster Mobile Websites
deanohume
299
30k
Practical Orchestrator
shlominoach
182
9.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
659
120k
Git: the NoSQL Database
bkeepers
PRO
422
63k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
GitHub's CSS Performance
jonrohan
1025
450k
Statistics for Hackers
jakevdp
789
220k
BBQ
matthewcrist
80
8.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
221
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
Agile that works and the tools we love
rasmusluckow
325
20k
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