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
ゆくKotlin くるRust
exoego
1
200
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
460
Combinatorial Interview Problems with Backtracking Solutions - From Imperative Procedural Programming to Declarative Functional Programming - Part 2
philipschwarz
PRO
0
140
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
0
1.2k
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
2.2k
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
210
ELYZA_Findy AI Engineering Summit登壇資料_AIコーディング時代に「ちゃんと」やること_toB LLMプロダクト開発舞台裏_20251216
elyza
2
1.1k
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
3.5k
PostgreSQLで手軽にDuckDBを使う!DuckDB&pg_duckdb入門/osc25hi-duckdb
takahashiikki
0
250
dchart: charts from deck markup
ajstarks
3
960
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
770
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
500
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.6k
Building Applications with DynamoDB
mza
96
6.9k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
87
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
150
Fireside Chat
paigeccino
41
3.8k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
Evolving SEO for Evolving Search Engines
ryanjones
0
100
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.5k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
110
Building the Perfect Custom Keyboard
takai
2
670
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