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
190
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
250
Testing value objects
franiglesias
0
230
Tests doubles: the motion picture
franiglesias
0
450
Low cost techniques for test doubles
franiglesias
0
170
Other Decks in Programming
See All in Programming
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
110
Flutter with Dart MCP: All You Need - 박제창 2025 I/O Extended Busan
itsmedreamwalker
0
150
Navigation 2 を 3 に移行する(予定)ためにやったこと
yokomii
0
160
はじめてのMaterial3 Expressive
ym223
2
290
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
120
Putting The Genie in the Bottle - A Crash Course on running LLMs on Android
iurysza
0
140
🔨 小さなビルドシステムを作る
momeemt
4
680
AI Coding Agentのセキュリティリスク:PRの自己承認とメルカリの対策
s3h
0
200
為你自己學 Python - 冷知識篇
eddie
1
350
1から理解するWeb Push
dora1998
7
1.9k
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
480
Featured
See All Featured
Become a Pro
speakerdeck
PRO
29
5.5k
For a Future-Friendly Web
brad_frost
180
9.9k
Typedesign – Prime Four
hannesfritz
42
2.8k
Speed Design
sergeychernyshev
32
1.1k
Optimizing for Happiness
mojombo
379
70k
The Cost Of JavaScript in 2023
addyosmani
53
8.9k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.2k
Site-Speed That Sticks
csswizardry
10
810
Designing Experiences People Love
moore
142
24k
Designing for Performance
lara
610
69k
Visualization
eitanlees
148
16k
Why Our Code Smells
bkeepers
PRO
339
57k
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