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
510
Low cost techniques for test doubles
franiglesias
0
210
Other Decks in Programming
See All in Programming
AgentCoreとHuman in the Loop
har1101
5
220
CSC307 Lecture 01
javiergs
PRO
0
690
Implementation Patterns
denyspoltorak
0
280
CSC307 Lecture 08
javiergs
PRO
0
670
CSC307 Lecture 02
javiergs
PRO
1
770
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
250
CSC307 Lecture 03
javiergs
PRO
1
490
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2k
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
250
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
170
Apache Iceberg V3 and migration to V3
tomtanaka
0
150
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
63
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Test your architecture with Archunit
thirion
1
2.1k
Designing for Timeless Needs
cassininazir
0
130
What does AI have to do with Human Rights?
axbom
PRO
0
2k
The Spectacular Lies of Maps
axbom
PRO
1
520
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
170
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Accessibility Awareness
sabderemane
0
49
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
55
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