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
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
310
Testing value objects
franiglesias
0
280
Tests doubles: the motion picture
franiglesias
0
530
Low cost techniques for test doubles
franiglesias
0
230
Other Decks in Programming
See All in Programming
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
260
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
390
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
220
AIとRubyの静的型付け
ukin0k0
0
420
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
3.9k
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.2k
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
390
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
310
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
490
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
170
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
11
3k
Hive Metastoreを通して学ぶIceberg REST Catalog ― 仕様から実装まで
okumin
0
300
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
850
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
74k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
390
The agentic SEO stack - context over prompts
schlessera
0
790
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
340
Between Models and Reality
mayunak
4
310
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
160
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
200
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Testing 201, or: Great Expectations
jmmastey
46
8.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