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
370
Introduction to TDD: Red-Green-Refactor
franiglesias
1
340
Testing value objects
franiglesias
0
300
Tests doubles: the motion picture
franiglesias
0
560
Low cost techniques for test doubles
franiglesias
0
250
Other Decks in Programming
See All in Programming
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
260
信頼性の目標を誰も求めてない
shubox
0
490
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
270
業務時間外もAIに働いてもらう話
colorful12
3
10k
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
630
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
740
新卒PdEのリアル
ryu1013
1
410
高専、大学編入、そして未踏へ〜プロダクト開発とキャリアの歩み - Technical College, University Transfer, and On to “Mitou” / My Journey in Product Development and Career
pkmiya
0
140
Laravelのアプリケーションをどこにデプロイするか #ツナギメオフライン.9
akase244
0
120
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
110
Oxlintはいいぞ(続)
yug1224
1
550
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
3
1k
Featured
See All Featured
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
840
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
420
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
410
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Deep Space Network (abreviated)
tonyrice
0
290
So, you think you're a good person
axbom
PRO
2
2.1k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
Leo the Paperboy
mayatellez
8
2.2k
Test your architecture with Archunit
thirion
2
2.4k
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