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
180
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
320
Introduction to TDD: Red-Green-Refactor
franiglesias
1
240
Testing value objects
franiglesias
0
220
Tests doubles: the motion picture
franiglesias
0
440
Low cost techniques for test doubles
franiglesias
0
160
Other Decks in Programming
See All in Programming
プロダクト志向なエンジニアがもう一歩先の価値を目指すために意識したこと
nealle
0
130
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
560
XP, Testing and ninja testing
m_seki
3
250
Team operations that are not burdened by SRE
kazatohiei
1
310
AI時代のソフトウェア開発を考える(2025/07版) / Agentic Software Engineering Findy 2025-07 Edition
twada
PRO
88
30k
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
120
Discover Metal 4
rei315
2
140
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
11k
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
760
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
200
Porting a visionOS App to Android XR
akkeylab
0
470
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
230
Featured
See All Featured
Become a Pro
speakerdeck
PRO
29
5.4k
Writing Fast Ruby
sferik
628
62k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
970
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
A better future with KSS
kneath
238
17k
Designing for Performance
lara
610
69k
Bash Introduction
62gerente
613
210k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Faster Mobile Websites
deanohume
307
31k
Agile that works and the tools we love
rasmusluckow
329
21k
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