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 the unpredictable
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Fran Iglesias
November 02, 2018
Programming
0
240
testing the unpredictable
Non deterministic tests
Fran Iglesias
November 02, 2018
Tweet
Share
More Decks by Fran Iglesias
See All by Fran Iglesias
Tips for daily refactoring
franiglesias
0
340
Introduction to TDD: Red-Green-Refactor
franiglesias
1
290
Testing value objects
franiglesias
0
270
Tests doubles: the motion picture
franiglesias
0
510
Low cost techniques for test doubles
franiglesias
0
210
Other Decks in Programming
See All in Programming
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
180
Unity6.3 AudioUpdate
cova8bitdots
0
120
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
240
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
130
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
400
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
230
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
220
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
4
500
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1.2k
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
7.9k
株式会社 Sun terras カンパニーデック
sunterras
0
2.1k
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.9k
Featured
See All Featured
Side Projects
sachag
455
43k
Code Reviewing Like a Champion
maltzj
528
40k
Music & Morning Musume
bryan
47
7.1k
The Language of Interfaces
destraynor
162
26k
Prompt Engineering for Job Search
mfonobong
0
180
The Invisible Side of Design
smashingmag
302
51k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
310
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.7k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
74
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
68
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Transcript
TDD 101 4. Testing the unpredictable
Testing the unpredictable
Testing the unpredictable Elements beyond our system: • Randomness •
Time • File system You can’t rely on their behavior
How can we test?
1. Things that are using unpredictable components They are global
state dependencies Isolate and extract Invert dependency Stub for testing
Example class User { private $id; private $name; public function
__construct(string $name) { $this->id = Uuid::uuid4(); $this->name = $name; } }
Example class User { private $id; private $name; public function
__construct( UserId $id, string $name ) { $this->id = $id; $this->name = $name; } }
2. Things that are unpredictable Don’t test what you don’t
own Test for properties of the output, not the output itself
Example class PasswordGeneratorTest extends TestCase { public function testShouldBeLongEnough() {
$password = $this->generator->generate(); $this->assertTrue(strlen($password) > 9); } }
Avoid coupling with dependency inversion
Dependency Inversion High level modules should not depend on low
level modules, both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions.
Thigh coupling MyClass Dependency Uses
Dependency inversion MyClass Interface Dependency Uses Implements
Dependency inversion & adapter pattern MyClass Interface Dependency Uses Implements
Adapter Uses
None