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
Fran Iglesias
November 02, 2018
Programming
250
0
Share
testing the unpredictable
Non deterministic tests
Fran Iglesias
November 02, 2018
More Decks by Fran Iglesias
See All by Fran Iglesias
Tips for daily refactoring
franiglesias
0
350
Introduction to TDD: Red-Green-Refactor
franiglesias
1
300
Testing value objects
franiglesias
0
280
Tests doubles: the motion picture
franiglesias
0
530
Low cost techniques for test doubles
franiglesias
0
230
Other Decks in Programming
See All in Programming
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
1.4k
20260514_its_the_context_window_stupid.pdf
heita
0
410
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
190
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
970
実用!Hono RPC2026
yodaka
2
300
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
120
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
640
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
140
Firefoxにコントリビューションして得られた学び
ken7253
2
150
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
140
空間オーディオの活用
objectiveaudio
0
130
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
1.6k
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Code Reviewing Like a Champion
maltzj
528
40k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
450
How STYLIGHT went responsive
nonsquared
100
6.1k
Side Projects
sachag
455
43k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
120
Writing Fast Ruby
sferik
630
63k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
490
Tell your own story through comics
letsgokoyo
1
910
Mobile First: as difficult as doing things right
swwweet
225
10k
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