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
240
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
340
Introduction to TDD: Red-Green-Refactor
franiglesias
1
290
Testing value objects
franiglesias
0
270
Tests doubles: the motion picture
franiglesias
0
520
Low cost techniques for test doubles
franiglesias
0
220
Other Decks in Programming
See All in Programming
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
200
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
290
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
260
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
700
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
1.2k
AIと共にエンジニアとPMの “二刀流”を実現する
naruogram
0
110
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
150
存在論的プログラミング: 時間と存在を記述する
koriym
5
680
「速くなった気がする」をデータで疑う
senleaf24
0
110
おれのAgentic Coding 2026/03
tsukasagr
1
120
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
4
2.2k
The free-lunch guide to idea circularity
hollycummins
0
390
Featured
See All Featured
Thoughts on Productivity
jonyablonski
75
5.1k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
120
Bash Introduction
62gerente
615
210k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
500
What's in a price? How to price your products and services
michaelherold
247
13k
Context Engineering - Making Every Token Count
addyosmani
9
780
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
190
Tell your own story through comics
letsgokoyo
1
880
Practical Orchestrator
shlominoach
191
11k
Utilizing Notion as your number one productivity tool
mfonobong
4
280
Marketing to machines
jonoalderson
1
5.1k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
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