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
300
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
おれのAgentic Coding 2026/03
tsukasagr
1
140
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
210
CDK Deployのための ”反響定位”
watany
4
750
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
380
AIエージェントで業務改善してみた
taku271
0
520
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
130
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
210
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
920
ハンズオンで学ぶクラウドネイティブ
tatsukiminami
0
130
[RubyKaigi 2026] Require Hooks
palkan
0
110
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
170
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
210
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Embracing the Ebb and Flow
colly
88
5k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
110
Statistics for Hackers
jakevdp
799
230k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
110
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
520
エンジニアに許された特別な時間の終わり
watany
106
240k
Automating Front-end Workflow
addyosmani
1370
200k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
53k
Docker and Python
trallard
47
3.8k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.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