Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
55
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
140
Windows Automation - Howard Feldman
lvrug
0
78
Separating Your Application from Rails - Brian Hughes
lvrug
0
130
SWIG and Ruby - David Grayson
lvrug
0
83
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
130
The Hamster Gem - Ryan Mulligan
lvrug
1
98
Varnish+Redis - Russ Smith
lvrug
1
110
Lambdas and Pops - Jan Hettich
lvrug
0
86
Making Good Use of Fonts - Russ Smith
lvrug
1
95
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Visualization
eitanlees
150
16k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
How STYLIGHT went responsive
nonsquared
100
5.9k
Site-Speed That Sticks
csswizardry
13
990
Agile that works and the tools we love
rasmusluckow
331
21k
Being A Developer After 40
akosma
91
590k
Raft: Consensus for Rubyists
vanstee
141
7.2k
Six Lessons from altMBA
skipperchong
29
4.1k
The Pragmatic Product Professional
lauravandoore
37
7.1k
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