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
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
CSC307 Lecture 06
javiergs
PRO
0
680
今から始めるClaude Code超入門
448jp
8
8.6k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
520
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
20
7k
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
220
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
550
CSC307 Lecture 07
javiergs
PRO
0
550
Package Management Learnings from Homebrew
mikemcquaid
0
210
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Tell your own story through comics
letsgokoyo
1
810
Paper Plane
katiecoart
PRO
0
46k
The agentic SEO stack - context over prompts
schlessera
0
630
The browser strikes back
jonoalderson
0
360
Making Projects Easy
brettharned
120
6.6k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
580
Ethics towards AI in product and experience design
skipperchong
2
190
The SEO Collaboration Effect
kristinabergwall1
0
350
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
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