SlideShare a Scribd company logo
Write Antifragile & Domain-Driven
Tests with
• THOMAS PIERRAIN
(@TPIERRAIN)
ACCEPTANCE TESTS
(COARSE-GRAINED “UNIT” TESTS)
UNIT TESTS
(FINE-GRAINED)
CONTRACT TESTS
INTEGRATION TESTS
QA
SMOKE TESTS
EXPLORATORY TESTS
END-TO-END TESTS
OUTSIDE-IN
DIAMOND
TDD
Disclaimers
There is no silver bullet Your testing strategy & techniques must always be
chosen accordingly to your context (both human & technical)
As long as you understand your trade-offs there is no reason not to
explore new paths…
Thanks to Kent Beck, Martin Fowler, Michael Feathers, Nat Pryce & Steve Freeman for their great source of
inspiration over the years #shouldersOfGiants
Preamble
BFF API
Booking
API
E-commerce
CRS API
Central
Reservation
U
d
PSP
API
Payment
U
d
• THOMAS PIERRAIN
(@TPIERRAIN)
Metasearch
API
Distribution
U
d
Resorts
Referential
CMS
API
Property
Management
System (PMS)
Stay
U
d
U
d
Rates &
Cancellation rules
API
Revenue Mgmt
U
d
U
d
Hospitality
U
d
Accounts
API
Loyalty
API
Marketing
DDD
LOVES…
(Contextualized)
Services
E-commerce
Central
Reservation
U
d
Payment
U
d
• THOMAS PIERRAIN
(@TPIERRAIN)
Distribution
U
d
Resorts
Referential
Stay
U
d
U
d
Revenue Mgmt
U
d
U
d
U
d
Marketing
Accounts
API
Loyalty
API
DDD
LOVES…
(Contextualized)
Services
BFF API
Booking
API
CMS
API
PSP
API
CRS API
Rates &
Cancellation rules
API
Metasearch
API
Property
Management
System (PMS)
Hospitality
• THOMAS PIERRAIN
(@TPIERRAIN)
DDD (& TDD)
ALSO
LOVES… DOMAIN
HTTP
HTTP
API
INFRASTRUCTURE
OUR WEB API
Ports &
Adapters
• THOMAS PIERRAIN
(@TPIERRAIN)
DDD (& TDD)
ALSO
LOVE… DOMAIN
HTTP INFRASTRUCTURE
OUR WEB API
Ports &
Adapters
Easy to test
Protect Domain code from
Infra fads
Quick feedback
(carpaccio-style slicing)
Allow late
architectural decisions
Composable:
modular-monolith ready HTTP
API
• THOMAS PIERRAIN
(@TPIERRAIN)
DDD (& TDD)
ALSO
LOVE… DOMAIN
INFRASTRUCTURE
Ports &
Adapters
• THOMAS PIERRAIN
(@TPIERRAIN)
DDD (& TDD)
ALSO
LOVE… DOMAIN
HTTP INFRASTRUCTURE
OUR WEB API
Ports &
Adapters
HTTP
API
Let’s talk about tests!
• THOMAS PIERRAIN
(@TPIERRAIN)
Different
Types
A WORLD
OF TESTS
ET Exploratory Tests (E2E)
IT Integration Tests (Contract)
AT
(coarse-grained unit)
Acceptance Tests
UT (fine-grained) Unit Tests
Why do I do TDD?
Made me…
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
More relaxed
More efficient
More relevant
TDD Workflows
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
AT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
AT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT AT
AT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT AT
AT
AT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT AT
AT
AT
AT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT AT
AT
AT
AT
AT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT AT
AT
AT
AT
AT
AT
Outside-in
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
AT
AT
AT
AT
AT
AT
AT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
UT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
UT
UT
API
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
UT
UT
API UT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
UT
UT
API UT
UT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
API
UT
UT
UT
UT
UT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
API
UT
UT
UT
UT
UT
UT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
API
UT
UT
UT
UT
UT
UT
UT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
API
UT
UT
UT
UT
UT
UT
UT
AT
Inside-out
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
API
UT
UT
UT
UT
UT
UT
UT
AT
AT
Workflows
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
Outside-in Inside-out
A
P
I
…
…
A
P
I
Common pitfalls & mitigations
• THOMAS PIERRAIN
(@TPIERRAIN)
Beware of…
TEST
DRIVEN
DEVELOP
MENT
1. Fragile tests
2. Blind spots
3. Complex setups
TEST
DRIVEN
DEVELOP
MENT
1.
Beware of…
Fragile tests
uses
API
uses
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
AT
UT
UT
UT
UT
UT
UT
AT
uses
API
1.
Beware of…
Fragile tests
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT UT
UT
AT
UT
UT
UT
UT
AT
uses
API
Now we want to change
our implementation here
1.
Beware of…
Fragile tests
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT UT
UT
AT
UT
UT
UT
UT
AT
uses
API
1.
Beware of…
Fragile tests
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT UT
UT
AT
UT
UT
UT
UT
AT
😕
😕 😕
😕
😕
uses
API
1.
Beware of…
Fragile tests
😕
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT UT
UT
AT
UT
UT
UT
UT
AT
😕
😕 😕
😕
😕
uses
API
Fragile tests
➔ Less refactoring
😕
• THOMAS PIERRAIN
(@TPIERRAIN)
UT
UT
AT
UT
UT
UT
UT
AT
😕
😕 😕
😕
😕
uses
API
TEST
DRIVEN
DEVELOP
MENT
Fragile tests
MITIGATIONS
• Do not test “implementations”
• Focus on external behaviours
instead (with Outside-in TDD)
• Favor (coarse-grained unit)
Acceptance tests over fine-
grained unit tests
A
P
…
…
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT Disclaimer
Test Coverage will be a visual help to
identify blind spots in our code here
It doesn’t mean that test coverage is a
must
2.
Beware of…
Blind Spots
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
DOMAIN
HTTP
HTTP
API
INFRASTRUCTURE
OUR WEB API
2.
Beware of…
Blind Spots
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
DOMAIN
Test the domain code with
{ acceptance | unit tests }
2.
Beware of…
Blind Spots
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
DOMAIN
HTTP
API
Test the domain code with
{ acceptance | unit tests }
Test the infra code (i.e. Adapters) with
contract (integration) tests
2.
Beware of…
Blind Spots
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
2.
Beware of…
Blind Spots
IT
IT
IT
IT
HTTP
API

CONTRACT TESTS
DOMAIN
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
100% covered
by Acceptance
Tests
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
2.
Beware of…
Blind Spots
IT
IT
IT
IT
HTTP
API

CONTRACT TESTS
DOMAIN
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
100% covered
by Acceptance
Tests
As DEV we
to write Domain-
Driven tests
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
2.
Beware of…
Blind Spots
IT
IT
IT
IT
HTTP
API

CONTRACT TESTS
DOMAIN
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
100% covered
by Acceptance
Tests
As DEV we
to write Domain-
Driven tests
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
2.
Beware of…
Blind Spots
As DEV we don’t write
enough integration tests
Because they are slow to
run & boring
➔ BUGS
IT
IT
IT
IT
HTTP
API

CONTRACT TESTS
DOMAIN
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
100% covered
by Acceptance
Tests
As DEV we
to write Domain-
Driven tests
As DEV we don’t write
enough integration tests
Because they are slow to
run & boring
➔ BUGS
IT
IT
IT
IT
HTTP
API

CONTRACT TESTS
DOMAIN
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
AT
100% covered
by Acceptance
Tests
As DEV we
to write Domain-
Driven tests
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
Blind Spots
MITIGATIONS
• Detect bugs in Adapters
via our beloved Acceptance
tests
• Include the Adapters code
and stub only the I/Os
BUGS
• THOMAS PIERRAIN
(@TPIERRAIN)
TEST
DRIVEN
DEVELOP
MENT
3.
Beware of…
Complex
setups
• THOMAS PIERRAIN
(@TPIERRAIN)
Test Suite for Rooms Availability
TEST
DRIVEN
DEVELOP
MENT
3.
Beware of…
Complex
setups
740 lines of Init()
• THOMAS PIERRAIN
(@TPIERRAIN)
Test Suite for Rooms Availability
TEST
DRIVEN
DEVELOP
MENT
3.
Beware of…
Complex
setups
740 lines of Init()
• THOMAS PIERRAIN
(@TPIERRAIN)
Test Suite for Rooms Availability
TEST
DRIVEN
DEVELOP
MENT
3.
Beware of…
Complex
setups
740 lines of Init()
• THOMAS PIERRAIN
(@TPIERRAIN)
Test Suite for Rooms Availability
TEST
DRIVEN
DEVELOP
MENT
3.
Beware of…
Complex
setups
Tests using initialized fields
➔ side effects nightmare
• THOMAS PIERRAIN
(@TPIERRAIN)
MITIGATIONS
• Avoid cognitive overload as much as
possible
The power of sameness
• Favor local variables over test suite
members
Everything should be created from the test
• Use Domain-Driven Builders to shorten
and explicit the Arrange section of your
tests
• Treat your test code as production code!
➔ merciless refactoring
TEST
DRIVEN
DEVELOP
MENT
3.
Beware of…
Complex
setups
• THOMAS PIERRAIN
(@TPIERRAIN)
Beware of…
TEST
DRIVEN
DEVELOP
MENT
1. Fragile tests
2. Blind spots
3. Complex setups
• THOMAS PIERRAIN
(@TPIERRAIN)
1. Fragile tests
2. Blind spots
3. Complex setups
Mitigations
TEST
DRIVEN
DEVELOP
MENT
• THOMAS PIERRAIN
(@TPIERRAIN)
1. Fragile tests
2. Blind spots
3. Complex setups
Mitigations
TEST
DRIVEN
DEVELOP
MENT
• THOMAS PIERRAIN
(@TPIERRAIN)
1. Fragile tests
2. Blind spots
3. Complex setups
Mitigations
TEST
DRIVEN
DEVELOP
MENT
Outside-in Diamond TDD
Outside-in Diamond TDD
Outside-in Diamond TDD
• THOMAS PIERRAIN
(@TPIERRAIN)
Outside-in
but…
TEST
DRIVEN
DEVELOP
MENT
Double loop?
• THOMAS PIERRAIN
(@TPIERRAIN)
Outside-in
but…
TEST
DRIVEN
DEVELOP
MENT
Double loop
• THOMAS PIERRAIN
(@TPIERRAIN)
Outside-in
but…
TEST
DRIVEN
DEVELOP
MENT
Double loop
One and a half loop
( )
OUTSIDE-IN
DIAMOND
OUTSIDE-IN
DIAMOND
OUTSIDE-IN
DIAMOND
Read it as a sentence divided into 2 parts
+
OUTSIDE-IN
DIAMOND
Fuzzers help us
- to randomly detect hard-coded values
or unsupported cases
OUTSIDE-IN
DIAMOND
Fuzzers help us
- to randomly detect hard-coded values
or unsupported case
- to shorten our test setup
OUTSIDE-IN
DIAMOND
Builders allow Behavioral
& Domain-Driven intentions
(no tech details here)
OUTSIDE-IN
DIAMOND
Builders allow Behavioral
& Domain-Driven intentions
(no tech details here)
OUTSIDE-IN
DIAMOND
Builders allow Behavioral
& Domain-Driven intentions
(no tech details here)
OUTSIDE-IN
DIAMOND
Builders allow Behavioral
& Domain-Driven intentions
(no tech details here)
OUTSIDE-IN
DIAMOND
Builders allow Behavioral
& Domain-Driven intentions
(no tech details here)
OUTSIDE-IN
DIAMOND
Builders allow Behavioral
& Domain-Driven intentions
(no tech details here)
Very important!
OUTSIDE-IN
DIAMOND
We test from the left-side Adapter
(here a web controller)
Injecting the result of our builder
OUTSIDE-IN
DIAMOND
We define the end-user request
No I/O here, but we test
the whole { black-box / component / API }
OUTSIDE-IN
DIAMOND
Helper method to sum-up in “one line”
our assert intention
OUTSIDE-IN
DIAMOND
“One line” to hide our
technical assertions
towards DTOs etc.
OUTSIDE-IN
DIAMOND
“One line” to hide our
technical assertions
towards DTOs etc.
“One line” to reuse the same
check intention, but with
various adapters
OUTSIDE-IN
DIAMOND
OUTSIDE-IN
DIAMOND
OUTSIDE-IN
DIAMOND
OUTSIDE-IN
DIAMOND
OUTSIDE-IN
DIAMOND
OUTSIDE-IN
DIAMOND
ARRANGE
ACT
ASSERT
OUTSIDE-IN
DIAMOND
ARRANGE
ACT
ASSERT
Fuzzers to shorten & speed setup
Builders to shorten and
“domain-driven” our test setup
OUTSIDE-IN
DIAMOND
Domain-Driven!
Live code
Wrap up
Outside-in Diamond TDD
• Elaborated from & for the people
• Write fast & Antifragile tests
( refactoring )
• DDD but covers more blind spots
on the tech side
Outside-in Diamond TDD
• Elaborated from & for the people
• Write fast & Antifragile tests
( refactoring )
• DDD but covers more blind spots
on the tech side
Any Questions?
BINARY IS FOR MACHINE
CODE IS FOR PEOPLE
WE CARE PEOPLE
Special thanks to: Bruno BOUCARD, Cyrille DUPUYDAUBY & Rui CARVALHO for their kind reviews & feedbacks

More Related Content

PPT
XP through TDD
KEY
Testing smells
PDF
Don't let your tests slow you down
PPTX
Test-Driven Design Insights@DevoxxBE 2023.pptx
PDF
Agile Software Testing the Agilogy Way
PDF
Functional tests with the FEST framework
PDF
Continuous Testing With React Storybook & WebdriverIO
PDF
Performance - a challenging craft
XP through TDD
Testing smells
Don't let your tests slow you down
Test-Driven Design Insights@DevoxxBE 2023.pptx
Agile Software Testing the Agilogy Way
Functional tests with the FEST framework
Continuous Testing With React Storybook & WebdriverIO
Performance - a challenging craft

Similar to Write Antifragile & Domain-Driven tests with ”Outside-in diamond” ◆ TDD (20)

PDF
Owasp tds
PDF
Implementing Test Automation in Agile Projects
PDF
Acceptance Testing of Web UI
PPTX
Implementing Test Automation in Agile Projects
PDF
Clean tests
PDF
Next-Level API Automation Testing Techniques – Part 1
PPTX
Tdd Ugialtnet Jan2010
PPTX
[SC London] "Testing Microservices: from Development to Production
PPTX
Introduction to Testing and TDD
KEY
ATDD in Practice
PPTX
Test execution
PDF
GTAC 2014: What lurks in test suites?
PDF
QA Meetup at Signavio (Berlin, 06.06.19)
PDF
Intro to JavaScript Testing
PDF
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
PDF
Hardening
PDF
Atdd for web apps
PDF
Intro To JavaScript Unit Testing - Ran Mizrahi
PDF
Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev
PDF
(automatic) Testing: from business to university and back
Owasp tds
Implementing Test Automation in Agile Projects
Acceptance Testing of Web UI
Implementing Test Automation in Agile Projects
Clean tests
Next-Level API Automation Testing Techniques – Part 1
Tdd Ugialtnet Jan2010
[SC London] "Testing Microservices: from Development to Production
Introduction to Testing and TDD
ATDD in Practice
Test execution
GTAC 2014: What lurks in test suites?
QA Meetup at Signavio (Berlin, 06.06.19)
Intro to JavaScript Testing
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Hardening
Atdd for web apps
Intro To JavaScript Unit Testing - Ran Mizrahi
Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev
(automatic) Testing: from business to university and back
Ad

More from Thomas Pierrain (20)

PDF
The scale-up, the autonomy and the nuclear submarine
PDF
Hexagonal And Beyond
PDF
La scale-up, l'autonomie et le sous-marin nucléaire
PDF
De l'autre côté du miroir
PDF
PDF
Beyond Hexagonal architecture
PDF
The 9 rules of debugging
PDF
Hexagonal architecture vs Functional core / Imperative shell
PDF
Une nuit dans l'hexagone
PDF
Equiper sa voie
PDF
As time goes by (episode 2)
PDF
Et si on parlait Éthique ?
PDF
Sortir de notre zone de confort
PDF
L'Agilité a grande échelle : conserver l'esprit, pas la lettre
PDF
Legacy club (english version)
PDF
The art of Software Design
PDF
CQRS without event sourcing
PDF
Async await...oh wait!
PDF
Decouvrir CQRS (sans Event sourcing) par la pratique
PPTX
Decouvrir son sujet grace à l'event storming
The scale-up, the autonomy and the nuclear submarine
Hexagonal And Beyond
La scale-up, l'autonomie et le sous-marin nucléaire
De l'autre côté du miroir
Beyond Hexagonal architecture
The 9 rules of debugging
Hexagonal architecture vs Functional core / Imperative shell
Une nuit dans l'hexagone
Equiper sa voie
As time goes by (episode 2)
Et si on parlait Éthique ?
Sortir de notre zone de confort
L'Agilité a grande échelle : conserver l'esprit, pas la lettre
Legacy club (english version)
The art of Software Design
CQRS without event sourcing
Async await...oh wait!
Decouvrir CQRS (sans Event sourcing) par la pratique
Decouvrir son sujet grace à l'event storming
Ad

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
AI in Product Development-omnex systems
PDF
top salesforce developer skills in 2025.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
history of c programming in notes for students .pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
System and Network Administraation Chapter 3
PPTX
L1 - Introduction to python Backend.pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Introduction to Artificial Intelligence
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Nekopoi APK 2025 free lastest update
Design an Analysis of Algorithms II-SECS-1021-03
AI in Product Development-omnex systems
top salesforce developer skills in 2025.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
Upgrade and Innovation Strategies for SAP ERP Customers
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
history of c programming in notes for students .pptx
Wondershare Filmora 15 Crack With Activation Key [2025
System and Network Administraation Chapter 3
L1 - Introduction to python Backend.pptx
Understanding Forklifts - TECH EHS Solution
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Reimagine Home Health with the Power of Agentic AI​
Introduction to Artificial Intelligence
Which alternative to Crystal Reports is best for small or large businesses.pdf

Write Antifragile & Domain-Driven tests with ”Outside-in diamond” ◆ TDD