Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
testing the unpredictable
Search
Fran Iglesias
November 02, 2018
Programming
0
220
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
330
Introduction to TDD: Red-Green-Refactor
franiglesias
1
270
Testing value objects
franiglesias
0
250
Tests doubles: the motion picture
franiglesias
0
490
Low cost techniques for test doubles
franiglesias
0
200
Other Decks in Programming
See All in Programming
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
240
React Native New Architecture 移行実践報告
taminif
1
150
AIコードレビューがチームの"文脈"を 読めるようになるまで
marutaku
0
350
sbt 2
xuwei_k
0
260
dotfiles 式年遷宮 令和最新版
masawada
1
750
生成AIを利用するだけでなく、投資できる組織へ
pospome
1
250
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
380
AIコーディングエージェント(Gemini)
kondai24
0
200
Developing static sites with Ruby
okuramasafumi
0
260
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
18
7.3k
認証・認可の基本を学ぼう後編
kouyuume
0
180
20 years of Symfony, what's next?
fabpot
2
350
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.7k
The Pragmatic Product Professional
lauravandoore
37
7.1k
[SF Ruby Conf 2025] Rails X
palkan
0
500
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
How to train your dragon (web standard)
notwaldorf
97
6.4k
A Tale of Four Properties
chriscoyier
162
23k
How STYLIGHT went responsive
nonsquared
100
6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
A designer walks into a library…
pauljervisheath
210
24k
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