SlideShare a Scribd company logo
1 of 17
Come testare il
comportamento del
dominio
Grazie Avanscoperta
CQRS/ES rapidamente
https://codeopinion.com
Scenario
• Gestione delle prenotazioni di una multisala
• Funzionamento simile a Eventbrite, si hanno
10 minuti di tempo per finalizzare l’ordine e
bloccare definitivamente i posti
• I posti mutano dallo stato «Free» a
«Reserved» a «Booked»
Il Command Handler
https://github.com/CQRS-Muflone/CQRS-ES_testing_workshop
L’aggregato
https://github.com/CQRS-Muflone/CQRS-ES_testing_workshop
Come lo testiamo?
• Solo con gli unit test?
• Non ci limiteremmo alla singola funzione o
le proprietà?
• Sono sufficienti a rappresentare le
complessità del dominio?
• Non è meglio testare il comportamento?
Un esperimento fatto anni fa
https://github.com/Iridio/CQRS-ES_MembershipProvider
Domande?
Proviamo lo specification
testing
• I test dovrebbero essere capaci di
rappresentare con semplicità qualunque
comportamento complesso
• Devono essere comprensibili da tutti
• Rappresentano il pensiero dietro il design
dell’aggregato
• “Given, When, Then” con gli eventi, i
comandi ed i Command Handler
Given, When, Then
• L’idea essenziale è quella di suddividere
uno scenario in tre sezioni:
• Given: descrive lo stato dell’aggregato prima
di inviare il comando. Una sorta di
prerequisito del test.
• When: rappresenta il comando da inviare
all’aggregato.
• Then/Expect: descrive i cambiamenti di
stato che ci si aspetta in seguito al
comando.
Primo esempio pratico
https://github.com/CQRS-Muflone/CQRS-ES_testing_workshop
Vediamone uno più complesso
https://github.com/CQRS-Muflone/CQRS-ES_testing_workshop
Command Specification
https://github.com/CQRS-Muflone/Muflone.SpecificationTests
Domande?
Bibliografia
• Domain-Driven Design: Tackling Complexity in
the Heart of Software (E. Evans)
https://www.amazon.it/Domain-Driven-Design-Tackling-
Complexity-Software-ebook/dp/B00794TAUG
• Implementing Domain-Driven Design (V.
Vernon)
https://www.amazon.it/Implementing-Domain-Driven-Design-
Vaughn-Vernon-ebook/dp/B00BCLEBN8/
• Introducing EventStorming (A. Brandolini)
https://leanpub.com/introducing_eventstorming
• REST in Practice: Hypermedia and Systems
Architecture (J. Webber)
https://www.amazon.it/REST-Practice-Hypermedia-Systems-
Architecture/dp/0596805829
• Enterprise Integration Patterns (G. Hohpe)
https://www.amazon.it/Enterprise-Integration-Patterns-Designing-
Deploying/dp/0321200683/
THANKS!
You can find us at:
▫ @collaalessandro
▫ alessandrocolla
▫ alessandro.colla@evoluzionetelematica.it
▫ @aacerbis
▫ https://www.linkedin.com/in/aacerbis/
▫ alberto.acerbis@4solid.it

More Related Content

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Come testare il comportamento del dominio

Editor's Notes

  1. Esempio semplice di gestione del comando ed emissione dell’evento Se non sai come funziona questo codice…vieni al nostro corso :D
  2. Esempio semplice di gestione del comando ed emissione dell’evento Se non sai come funziona questo codice…vieni al nostro corso :D
  3. Testare le proprietà di un messaggio, che per sua natura, in un’architettura simile, è immutabile non ha particolare significato
  4. Timebox 5 minuti
  5. Timebox 5 minuti