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
0
230
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
280
Testing value objects
franiglesias
0
260
Tests doubles: the motion picture
franiglesias
0
500
Low cost techniques for test doubles
franiglesias
0
200
Other Decks in Programming
See All in Programming
CSC307 Lecture 04
javiergs
PRO
0
640
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
500
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
3
1.8k
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
130
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
670
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
120
CSC307 Lecture 01
javiergs
PRO
0
670
AIエージェントの設計で注意するべきポイント6選
har1101
6
3.2k
AtCoder Conference 2025
shindannin
0
960
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
3.5k
[AI Engineering Summit Tokyo 2025] LLMは計画業務のゲームチェンジャーか? 最適化業務における活⽤の可能性と限界
terryu16
2
360
CSC307 Lecture 02
javiergs
PRO
1
760
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
0
490
Test your architecture with Archunit
thirion
1
2.1k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
220
From π to Pie charts
rasagy
0
120
Into the Great Unknown - MozCon
thekraken
40
2.2k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
250
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
83
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
49
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
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