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
210
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
330
Introduction to TDD: Red-Green-Refactor
franiglesias
1
270
Testing value objects
franiglesias
0
250
Tests doubles: the motion picture
franiglesias
0
480
Low cost techniques for test doubles
franiglesias
0
190
Other Decks in Programming
See All in Programming
Phronetic Team with AI - Agile Japan 2025 closing
hiranabe
2
680
目的で駆動する、AI時代のアーキテクチャ設計 / purpose-driven-architecture
minodriven
11
3.5k
DartASTとその活用
sotaatos
2
150
生成AIを活用したリファクタリング実践 ~コードスメルをなくすためのアプローチ
raedion
0
140
All(?) About Point Sets
hole
0
210
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
2
9.5k
2025 컴포즈 마법사
jisungbin
0
150
データファイルをAWSのDWHサービスに格納する / 20251115jawsug-tochigi
kasacchiful
2
100
TypeScript 5.9 で使えるようになった import defer でパフォーマンス最適化を実現する
bicstone
1
490
AI駆動開発ライフサイクル(AI-DLC)のホワイトペーパーを解説
swxhariu5
0
1.5k
ゼロダウンタイムでミドルウェアの バージョンアップを実現した手法と課題
wind111
0
220
Module Harmony
petamoriken
2
560
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
697
190k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Done Done
chrislema
186
16k
Agile that works and the tools we love
rasmusluckow
331
21k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.2k
A better future with KSS
kneath
239
18k
Writing Fast Ruby
sferik
630
62k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Docker and Python
trallard
46
3.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
980
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
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