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
250
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
320
Testing value objects
franiglesias
0
280
Tests doubles: the motion picture
franiglesias
0
540
Low cost techniques for test doubles
franiglesias
0
240
Other Decks in Programming
See All in Programming
フィードバックで育てるAI開発
kotaminato
1
110
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.1k
スマートグラスで並列バイブコーディング
hyshu
0
280
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
140
OS アップデート対応の取り組み方がもっと共有されてほしい
andpad
0
110
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
840
Vite+ Unified Toolchain for the Web
naokihaba
0
730
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.3k
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
210
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
450
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
15
3.2k
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
170
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Why Our Code Smells
bkeepers
PRO
340
58k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
790
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Building the Perfect Custom Keyboard
takai
2
810
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.6k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
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