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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Fran Iglesias
November 02, 2018
Programming
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
360
Introduction to TDD: Red-Green-Refactor
franiglesias
1
330
Testing value objects
franiglesias
0
290
Tests doubles: the motion picture
franiglesias
0
550
Low cost techniques for test doubles
franiglesias
0
240
Other Decks in Programming
See All in Programming
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
260
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.6k
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
740
Claude Team Plan導入・ガイド
tk3fftk
0
250
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
340
霧の中の代数的エフェクト
funnyycat
1
450
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
160
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
790
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
180
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.1k
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
17k
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
170
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
230
Why Our Code Smells
bkeepers
PRO
340
58k
30 Presentation Tips
portentint
PRO
1
360
A Soul's Torment
seathinner
6
3.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
190
Thoughts on Productivity
jonyablonski
76
5.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
870
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Designing Experiences People Love
moore
143
24k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Ethics towards AI in product and experience design
skipperchong
2
340
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