SlideShare ist ein Scribd-Unternehmen logo
1 von 61
Test-Driven Design Insights
10 design hints you were missing
== The Deep Dive ==
Article: https://victorrentea.ro/blog/design-insights-from-unit-testing/
Code: https://github.com/victorrentea/unit-testing.git on branch: devoxx-be-2023
About Victor Rentea: https://victorrentea.ro
victorrentea.ro/training-offer
👋 Hi, I'm Victor Rentea 🇷🇴 PhD(CS): VictorRentea.ro
Java Champion, 18 years of code, 10 years of teaching
Consultant & Trainer for 120+ companies:
❤️ Clean Code, Architecture, Unit Testing
🛠 Spring, Hibernate, Reactive/WebFlux
⚡️ Java Performance, Secure Coding 🔐
Lots of Conference Talks on YouTube
Founder of European Software Crafters Community (6K members)
🔥 Free 1-hour webinars, after work 👉 victorrentea.ro/community
Past events on youtube.com/vrentea
Father of 👧👦, servant of a 🐈, weekend gardener 🌼 VictorRentea.ro
3
From the Agile (2001) Ideology ...
Emergent Design
While we keep shipping shit,
the design of the system design will naturally improve
(as opposed to large up-front design that caused overengineering in waterfall)
4
Writing Unit Tests
gives you those triggers!
Emergent Design
that never emerged
We need triggers
to start improving the design!
I f t e s t s a r e h a r d t o w r i t e ,
t h e d e s i g n s u c k s
5
Kent Beck
Creator of Extreme Programming (XP) in 1999
the most technical style of Agile
Inventor of TDD
Author of JUnit
Father of Unit Testing
6
1. Passes all Tests ⭐️
 Proves it works as intended
 Safe to refactor later
 Massive feedback on your design 💎
2. Clear, Expressive, Consistent, Domain names
2. No duplication = DRY🌵
3. Minimalistic = KISS💋, avoid overengineering
Rules of Simple Design
https://martinfowler.com/bliki/BeckDesignRules.html
Keep it Short and Simple!
by Kent Beck
7
History of Testing:
Ice-Cream Cone
What's this?
8
Testing Anti-Pattern
QA Team
30 manual testers
🧔🏼♂️🧔🏼♂️🧔🏼♂️🧔🏼♂️ 🧔🏼♂️🧔🏼♂️🧔🏼
🧔🏼♂️🧔🏼♂️🧔🏼♂️🧔🏼♂️🧔🏼♂️ ...
30% end-to-end coverage
using GUI robots, Selenium,..
absent (old technology stack)
scarce unit-tests, 10% coverage
Ice-Cream Cone
History of Testing:
Reality in many
Successful Monoliths today:
9 https://martinfowler.com/articles/practical-test-pyramid.html
E2E
Testing Pyramid
Test a thin slice of behavior
MOCKS
Test a group of modules
Test everything as whole
⭐️ Deep Edge Case
⭐️ Critical Business Flow (eg. checkout)
overlapping is expected
surface is proportional to quantity
10
MOCKS
💖 / 🤬
11
Why we 💖 Mocks
Isolated Tests
from external systems
Fast 👑
no framework, DB, external API
Test Less Logic
when testing high complexity 😵💫 
Alternatives:
- In-mem DB
- Testcontainers 🐳
- WireMock, ..
12
public computePrices(...) {
// A
for (Product product : products) { +1
// B
if (price == null) { +1
// C
}
for (Coupon coupon : customer.getCoupons()) { +1
if (coupon.autoApply() +1
&& coupon.isApplicableFor(product, price) +1
&& !usedCoupons.contains(coupon)) { +1
// D
}
}
}
return ...;
}
Code Complexity - Cyclomatic
- Cognitive (Sonar)
13
Logic
under test
Testing Complex Code
More execution paths through code => More tests
Test
Test
Test
Test
Test
Test
Test
complexity=5 =6
f(a) g(b)
calls
f() calling g() together have a complexity of up to ...
Too Many
(to cover all branches)
Too Heavy
(setup and input data)
Tests for f() calling g() become...
30
Test
Test
Test
Test
Test
Test
Test
Test
Test
Test
Test
Test
14
MOCK
15
Why we 💖 Mocks
Isolated Tests
from external systems
Fast 👑
no framework, DB, MQ, external API
Test Less Logic
when testing high complexity 😵💫 
Alternatives:
- In-mem DB (H2)
- Testcontainers 🐳
- WireMock, ..
🤨 Cheating
James Coplien in https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf
16
Why we 🤨 Mocks
Uncaught Bugs in Production 😱
despite 1000s of ✅GREEN tests
(lock, tap, doors, umbrella)
Fragile Tests 💔
that break at any refactoring
Unreadable Tests 😵💫
eg. a test using ≥ 5 mocks 
test
code
prod
code
18
19
Test has 20 lines full of mocks
😵💫
😡
BURN THE TEST!
bad cost/benefit ratio
HONEYCOMB TESTS
Prefer Integration/Social Tests
WHAT AM I TESTING HERE ?
syndrome
Tested prod code has 4 lines
😩
f(..) {
a = api.fetchB(repo1.find(..).getBId());
d = service.createD(a,b,repo2.find(..));
repo3.save(d);
mq.send(d.id);
}
g(dto) {
repo2.save(mapper.fromDto(dto, repo1.find(..)));
}
SIMPLIFY PRODUCTION
"Remove Middle-Man"
(inline method / collapse layer)
20 https://martinfowler.com/articles/practical-test-pyramid.html
End-to-end
The Testing Pyramid
21
The Legacy Monolith
can hide terrible complexity behind a few entry points
 Cover deep corners of logic with Unit Tests
Microservices
have more APIs (stable test surfaces),
hide less complexity (but more configuration risk)
 Test more at API-level (Integration)  Honeycomb Testing Strategy
22
Integration
(one microservice)
Integrated
(entire ecosystem)
Deploy all microservices in dockers / staging env
Expensive, slow, flaky tests
Use for business-critical flows (eg checkout)
Cover one microservice fully
Use for: Default for every flow ⭐️⭐️⭐️
Isolate tests without mocks
Cover 1 class/role (Solitary/Social Unit Tests)
Use for: naturally isolated pieces with high complexity.
@Mock are allowed
Honeycomb Testing Strategy
Testcontainers 🐳
WireMock
&co
Contract
Tests
(Pact, SCC)
DB ES Kafka ...
API
many tests on
one entry point
https://engineering.atspotify.com/2018/01/testing-of-microservices/
Implementation Detail
(a role)
complexity
decouple and
test in isolation
23
Unit Tests give you most Design Feedback 💎
More Complexity => Better Design
Implementation
Detail Tests
👍
MOCKS
complexity
You can black-box-test
horrible, terrible,
unmaintainable code
24
The Dawn of Mocks
(2004)
25
The Dawn of Mocks
(2004)
http://jmock.org/oopsla2004.pdf
26
BAD HABIT
Mock Roles, not Objects
http://jmock.org/oopsla2004.pdf
You implement a new feature
> ((click in UI/postman)) > It works > 🎉
Oh NO!! I forgot to write tests 😱
...then you write unit tests
blindly mocking all the dependencies
of the prod code you wrote
↓
Few years later:
"My tests are fragile and impede refactoring!"
Contract-Driven Design
Before mocking a dependency,
clarify its responsibility
=
After you mock an API, it freezes ❄️
(changing it = pain)
😭
27
strive to write
Social Unit Tests
for components (groups of objects) with a clear responsibility
✅ Internal refactoring of the component won't break the tests
❌ More complexity to understand! More mocks to face?
Instead of fine-grained Solitary Unit Tests testing one class in isolation,
A B
<
>
28
Unit Testing
= ?
29
"Unit Testing means mocking all dependencies of a class"
- common belief
"It's perfectly fine for unit tests to talk to databases and filesystems!"- Ian Cooper in TDD, Where Did It All Go Wrong
Unit Testing
= ?
Robust Unit Testing requires
identifying responsibilities
#0
30
Unit Testing tells you to simplify
signatures and data structures
#1
31
var bigObj = new BigObj();
bigObj.setA(a);
bugObj.setB(b);
prod.method(bigObj);
Tests must create bigObj just to pass two inputs🧔
method(bigObj)
MUTABLE
DATA 😱
in 2023?
using only 2 of the 15 fields in bigObj
method(a, b)
Precise Signatures prod.method(a, b);
Also, simpler tests:
Pass only necessary data to functions ✅
when(bigObj.getA()).thenReturn(a);
⛔️ Don't Mock Getters ⛔️
prod.horror(new ABC(a, b, c));
horror(abc)
Parameter Object
class ABC {a,b,c}
When testing highly complex logic, introduce a
⛔️ Don't return Mocks from Mocks ⛔️
(mockA)
✅ Mock behavior. ✅ Construct test data.
32
🏰
Constrained Objects
= data structures that throw exceptions on invalid data
Customer{email ≠ null}, Interval{start<end}
 Mutable: Domain Entities, Aggregates
 Immutable❤️: Value Objects
33
❶ A Constrained Object gets Large
↓
Object Mother Pattern
TestData.customer(): a valid Customer
coupling
Break Domain Entities
InvoicingCustomer | ShippingCustomer
in separate Bounded Contexts
packages > modules > microservices
❷ Integration and Social Unit Tests❤️
require heavy data inputs
* https://martinfowler.com/bliki/ObjectMother.html (2006)
Same Object Mother used in different verticals
invoicing | shipping
↓
Split Object Mother per vertical
InvoicingTestData | ShippingTestData
Creating valid test data gets cumbersome
CREEPY
A large class shared by many tests
Don't change it: only add code (lines/methods).
Each tests can tweak the objects for their case.
✅ TestData.musk(): Customer (a persona)
🏰
34
Object Mother
to unmarshal JSONs from /src/test/resource
🧔
35
Tests require detailed understanding of:
External API/DTOs
The Library: to mock it
dto = externalApi.call(apiDetails);
... dto.getFooField()
... Lib.use(mysteriousParam,...)
Tests should speak your Domain Language
#respect4tests
Agnostic Domain
Isolate complex logic from external world
via Adapters
obj = clientAdapter.call(domainStuff)
... myDomainObject.getMyField()
... libAdapter.use(😊)
Your complex logic directly uses
External API/DTOss or heavy libraries:
36
application / infra
My DTOs
External
API
External
DTOs
Clien
t
External
System
Application
Service
Simplified Onion Architecture
(more in my "Clean Pragmatic Architecture"
at Devoxx Ukraine 2021 on YouTube)
Value Object
Entity
id
Domain
Service
Domain
Service
agnostic
domain
Repo
IAdapter
Adapter
⛔️
⛔️
IWrapper
Ugly Library
Domain Complexity Protected Inside
37
#1 Unit Testing encourages
Minimal Signatures
Tailored Data Structures
Agnostic Domain
38
#2 Unit Testing tells you to break
Highly Complex Logic
39
Any problem in computer science
can be solved by introducing
another level of abstraction.
- David Wheeler (corrupted quote)
40
class BigService {
f() { //complex
g();
}
g() { //complex
}
}
Inside the same class,
a complex function f()
calls a complex g()
g() grew complex => unit-test it alone?
When testing f(), can I avoid entering g()?
Can I mock a local method call?
class HighLevel {
LowLevel low;
f() {//complex
low.g();
}
} class LowLevel {
g() {/*complex*/}
}
↓
Partial Mock (@Spy)
Hard to understand tests:
Which prod method is real, which is mocked?
🧔
Split by Layers of Abstraction
(high-level policy vs low-level details)
Only use it when
testing Legacy Code
If splitting the class breaks cohesion,
test f() + g() together with social unit tests
⛔️
41
class HighLevel {
LowLevel low;
f() {//complex
low.g();
}
}
Split by Layers of Abstraction
= vertical split of a class
class LowLevel {
g() {/*complex*/}
}
horizontal 
placeOrder(o)
processPayment(o)
42
class Wide {
A a;
B b; //+more dependencies
f() {..a.a()..}
g() {..b.b()..}
}
@ExtendWith(MockitoExtension)
class WideTest {
@Mock A a;
@Mock B b;
@InjectMocks Wide wide;
// 5 tests for f()
// 7 tests for g()
}
↓
Split the test class in WideFTest, WideGTest
(rule: the fixture should be used by all tests)
Unrelated complex methods in the same class
use different sets of dependencies:
class ComplexF {
A a;
f() {
..a.a()..
}
}
class ComplexG {
B b;
g() {
..b.b()..
}
}
@BeforeEach
void sharedFixture() {
when(a.a()).then...
when(b.b()).then...
}
Split Unrelated Complexity
Part of the setup
is NOT used by a test.
** Mockito (since v2.0) throws UnnecessaryStubbingException if a when..then is not used by a @Test, when using MockitoExtension
 Unmaintainable Tests
🧔
FIXTURE CREEP
= test setup
DRY
https://www.davidvlijmincx.com/posts/setting_the_strictness_for_mockito_mocks/
use
43
Split Unrelated Complexity
class ComplexF {
A a;
f() {
..a.a()..
}
}
class ComplexG {
B b;
g() {
..b.b()..
}
}
horizontally ↔️
getProduct() createProduct()
44
Vertical Slice Architecture (VSA)
https://jimmybogard.com/vertical-slice-architecture/
class GetProductUseCase {
@GetMapping("product/{id}")
GetResponse get(id) {
...
}
}
horizontally ↔️
Organize code by use-cases, not by layers
class CreateProductUseCase {
@PostMapping("product/{id}")
void create(CreateRequest) {
...
}
}
45
vertically ↕️
Tests help us to break complexity
horizontally ↔️
#2
clear roles
by
46
Should I mock it? – Practical Examples in a Spring app
Repository (eg Spring Data JpaRepository)?
✅YES: clear responsibility with stable API + expensive to integration test
Message Sender (eg RabbitTemplate)?
✅YES: clear responsibility, simple API + expensive to integration-test
Flexible library class (RestTemplate/WebClient) ?
❌NO: complex API  Integration Test with WireMock?
Adapter wrapping an external API call ?
✅YES: allow to keep your tests agnostic
Satellite class (simple DtoEntity mapper) ?
❌NO: too simple  Social / Integration Test
A logic component (@Service) ?
✅YES: if clear, non-trivial responsibility: NotificationService, UpdateProductStockService
❌NO if unclear role: ProductService doing "anything"  Social/Integration Test
A Data Structure (@Entity/@Document/Dto/...) ?
❌ don't mock  populate an instance
47
#3 Unit Testing promotes
Functional Programming values
Pure Functions &
Immutable Objects
48 VictorRentea.ro
a training by
No Side-Effects
(causes no changes)
INSERT, POST, send message, field changes, files
Same Input => Same Output
(no external source of data)
GET, SELECT, time, random, UUID …
Pure Functions
just calculates a value
aka
Referential
Transparent
49
No Network or files
No Changes to Data
No time or random
Pure Functions
(When using a DI container)
50
@VisibleForTesting
a = repo1.findById(..)
b = repo2.findById(..)
c = api.call(..)
🤯complexity🤯
repo3.save(d);
mq.send(d.id);
Complex logic
using many dependencies
(eg: computePrice, applyDiscounts)
Many tests
using lots of mocks
when(..).thenReturn(a);
when(..).thenReturn(b);
when(..).thenReturn(c);
prod.complexAndCoupled();
verify(..).save(captor);
d = captor.get();
assertThat(d)...
verify(..).send(...);
✅ Simpler tests (less mocks)
d = prod.pure(a,b,c);
assertThat(d)...
Reduce Coupling of Complex Logic
Clarify inputs/outputs
D pure(a,b,c) {
🤯complexity🤯
return d;
}
extract
method
51 © VictorRentea.ro
a training by
Complexity
State Mutation
DB
Imperative Shell
API call
Files
Complex Logic
Functional Core
52 © VictorRentea.ro
a training by
Complexity
State Mutation
DB
API call
Files
Complex Logic
/ Segregation
Imperative Shell Functional Core
53 © VictorRentea.ro
a training by
Functional
Core
Imperative Shell
Extract heaviest complexity
as pure functions
/ Segregation
Imperative Shell Functional Core
54 © VictorRentea.ro
a training by
Immutable Objects
=objects you can't modify after instantiation
- read-only fields: final, @lombok.Value, record
- referencing immutable objects: mind the collections!
To change them > produce a modified copy
55
method(Mutable order, discounts) {
ds.applyDiscounts(order, discounts);
var price = cs.computePrice(order);
return price;
}
... but you use mutable objects
bugs in production ❌
despite 4000 ✅ tests
You have 4.000 unit tests,
100% test coverage 😲
👏
↓
Paranoid Testing
(InOrder can verify method call order)
Immutable Objects
method(Immutable order, d) {
var discountedOrder = ds.applyDiscounts(order, d);
var price = cs.computePrice(discountedOrder);
return price;
}
TEMPORAL
COUPLING
compilation fails ❌
If you swap two lines ...
If you swap two lines ...
56
1. Collapse Middle-Man vs "What am I testing here?" Syndrome or bigger tests:
2. Honeycomb Testing Strategy = more Integration Tests over Fragile Unit Tests
3. Precise Signatures: simpler arguments, better names
4. Dedicated Data Structures vs Creepy Object Mother
5. Agnostic Domain vs mixing core logic with External-APIs or Heavy-Library calls
6. Split Complexity by Layers of Abstraction ↕️ vs Partial Mocks (aka spy)
7. Split Unrelated Complexity ↔️ vs Fixture Creep (large shared setup)
8. Clarify Roles, Social Unit Tests vs blindly mock all dependencies
9. Decouple Complexity in Pure Functions vs Many tests full of mocks
10.Immutable Objects vs Temporal Coupling
Design Hints from Tests
57
Aim for a
Testable Design
58
timeframe for developing your feature
When do you start writing tests?
✅ understand the problem
✅ early design feedback 💎 💎 💎
✅ confidence to refactor later
Too Late
TDD Early Enough
Writing unit tests early
increases friction with careless design
60
Unit Testing Reading Guide
1] Classic TDD⭐️⭐️⭐️ (mock-less) https://www.amazon.com/Test-Driven-Development-Kent-Beck
Mock Roles, not Objects ⭐️⭐️⭐️: http://jmock.org/oopsla2004.pdf
"Is TDD Dead?" https://martinfowler.com/articles/is-tdd-dead/
Why Most Unit Testing is Waste (James Coplien): https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf
vs Integrated Tests are a Scam(J Brains): https://blog.thecodewhisperer.com/permalink/integrated-tests-are-a-scam
2] London TDD⭐️⭐️⭐️ (mockist) https://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests +
Demo Exercise by Sandro Mancuso https://www.youtube.com/watch?v=XHnuMjah6ps
3] Patterns⭐️ https://www.amazon.com/Art-Unit-Testing-examples
4] https://www.amazon.com/xUnit-Test-Patterns-Refactoring-Code
5] (skip through) https://www.amazon.com/Unit-Testing-Principles-Practices-Patterns
Test-Driven Design Insights
Article: https://victorrentea.ro/blog/design-insights-from-unit-testing/
Code: https://github.com/victorrentea/unit-testing.git on branch: devoxx-be-2023
About Victor Rentea: https://victorrentea.ro
Stay connected. Join us:

Weitere ähnliche Inhalte

Was ist angesagt?

Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipVictor Rentea
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010guest5639fa9
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignVictor Rentea
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing ArchitecturesVictor Rentea
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignYoung-Ho Cho
 
The Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkThe Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkVictor Rentea
 
Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Victor Rentea
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 
Clean architecture
Clean architectureClean architecture
Clean architecture.NET Crowd
 
Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24Victor Rentea
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationOğuzhan Soykan
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
Integration testing with spring @snow one
Integration testing with spring @snow oneIntegration testing with spring @snow one
Integration testing with spring @snow oneVictor Rentea
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with XtextGlobalLogic Ukraine
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipIvan Paulovich
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy CodeAndrea Polci
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java ApplicationVictor Rentea
 

Was ist angesagt? (20)

Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing Architectures
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
The Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkThe Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring Framework
 
Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) Presentation
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Integration testing with spring @snow one
Integration testing with spring @snow oneIntegration testing with spring @snow one
Integration testing with spring @snow one
 
Entity Framework
Entity FrameworkEntity Framework
Entity Framework
 
DDD Introduction
DDD IntroductionDDD Introduction
DDD Introduction
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with Xtext
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software Craftsmanship
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java Application
 

Ähnlich wie Test-Driven Design Insights@DevoxxBE 2023.pptx

DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesFab L
 
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...DevSecCon
 
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...JSFestUA
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 
Unit testing - 9 design hints
Unit testing - 9 design hintsUnit testing - 9 design hints
Unit testing - 9 design hintsVictor Rentea
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfVictor Rentea
 
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power ToolsJavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power ToolsJorge Hidalgo
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindAndreas Czakaj
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Ukraine
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Gianluca Padovani
 
Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214David Rodenas
 

Ähnlich wie Test-Driven Design Insights@DevoxxBE 2023.pptx (20)

Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation Slides
 
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
 
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...
JS Fest 2018. Никита Галкин. Микросервисная архитектура с переиспользуемыми к...
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Coding Naked 2023
Coding Naked 2023Coding Naked 2023
Coding Naked 2023
 
Unit testing - 9 design hints
Unit testing - 9 design hintsUnit testing - 9 design hints
Unit testing - 9 design hints
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdf
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power ToolsJavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 
Mini training - Moving to xUnit.net
Mini training - Moving to xUnit.netMini training - Moving to xUnit.net
Mini training - Moving to xUnit.net
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code Testing
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
10 Ways To Improve Your Code
10 Ways To Improve Your Code10 Ways To Improve Your Code
10 Ways To Improve Your Code
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
NET Code Testing
NET Code TestingNET Code Testing
NET Code Testing
 
Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214
 

Mehr von Victor Rentea

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Distributed Consistency.pdf
Distributed Consistency.pdfDistributed Consistency.pdf
Distributed Consistency.pdfVictor Rentea
 
From Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxFrom Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxVictor Rentea
 
Software Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdfSoftware Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdfVictor Rentea
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021Victor Rentea
 
Hibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicHibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicVictor Rentea
 
Integration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzIntegration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzVictor Rentea
 
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021Victor Rentea
 
Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Victor Rentea
 
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Victor Rentea
 
Don't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using MocksDon't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using MocksVictor Rentea
 
Pure Functions and Immutable Objects
Pure Functions and Immutable ObjectsPure Functions and Immutable Objects
Pure Functions and Immutable ObjectsVictor Rentea
 
Definitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaDefinitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaVictor Rentea
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipVictor Rentea
 
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Victor Rentea
 

Mehr von Victor Rentea (18)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Distributed Consistency.pdf
Distributed Consistency.pdfDistributed Consistency.pdf
Distributed Consistency.pdf
 
From Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxFrom Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptx
 
OAuth in the Wild
OAuth in the WildOAuth in the Wild
OAuth in the Wild
 
Software Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdfSoftware Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdf
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021
 
Hibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicHibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the Magic
 
Integration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzIntegration testing with spring @JAX Mainz
Integration testing with spring @JAX Mainz
 
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
 
Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021
 
TDD Mantra
TDD MantraTDD Mantra
TDD Mantra
 
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
 
Don't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using MocksDon't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using Mocks
 
Pure Functions and Immutable Objects
Pure Functions and Immutable ObjectsPure Functions and Immutable Objects
Pure Functions and Immutable Objects
 
Definitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaDefinitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in Java
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
 

Kürzlich hochgeladen

What is a Recruitment Management Software?
What is a Recruitment Management Software?What is a Recruitment Management Software?
What is a Recruitment Management Software?NYGGS Automation Suite
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...naitiksharma1124
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConNatan Silnitsky
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfSrushith Repakula
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In sowetokasambamuno
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypseTomasz Kowalczewski
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAShane Coughlan
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfICS
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMarkus Moeller
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...OnePlan Solutions
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024SimonedeGijt
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024MulesoftMunichMeetup
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Eraconfluent
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Maxim Salnikov
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksJinanKordab
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Conceptsthomashtkim
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...Neo4j
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AIAGATSoftware
 

Kürzlich hochgeladen (20)

What is a Recruitment Management Software?
What is a Recruitment Management Software?What is a Recruitment Management Software?
What is a Recruitment Management Software?
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 

Test-Driven Design Insights@DevoxxBE 2023.pptx

  • 1. Test-Driven Design Insights 10 design hints you were missing == The Deep Dive == Article: https://victorrentea.ro/blog/design-insights-from-unit-testing/ Code: https://github.com/victorrentea/unit-testing.git on branch: devoxx-be-2023 About Victor Rentea: https://victorrentea.ro
  • 2. victorrentea.ro/training-offer 👋 Hi, I'm Victor Rentea 🇷🇴 PhD(CS): VictorRentea.ro Java Champion, 18 years of code, 10 years of teaching Consultant & Trainer for 120+ companies: ❤️ Clean Code, Architecture, Unit Testing 🛠 Spring, Hibernate, Reactive/WebFlux ⚡️ Java Performance, Secure Coding 🔐 Lots of Conference Talks on YouTube Founder of European Software Crafters Community (6K members) 🔥 Free 1-hour webinars, after work 👉 victorrentea.ro/community Past events on youtube.com/vrentea Father of 👧👦, servant of a 🐈, weekend gardener 🌼 VictorRentea.ro
  • 3. 3 From the Agile (2001) Ideology ... Emergent Design While we keep shipping shit, the design of the system design will naturally improve (as opposed to large up-front design that caused overengineering in waterfall)
  • 4. 4 Writing Unit Tests gives you those triggers! Emergent Design that never emerged We need triggers to start improving the design! I f t e s t s a r e h a r d t o w r i t e , t h e d e s i g n s u c k s
  • 5. 5 Kent Beck Creator of Extreme Programming (XP) in 1999 the most technical style of Agile Inventor of TDD Author of JUnit Father of Unit Testing
  • 6. 6 1. Passes all Tests ⭐️  Proves it works as intended  Safe to refactor later  Massive feedback on your design 💎 2. Clear, Expressive, Consistent, Domain names 2. No duplication = DRY🌵 3. Minimalistic = KISS💋, avoid overengineering Rules of Simple Design https://martinfowler.com/bliki/BeckDesignRules.html Keep it Short and Simple! by Kent Beck
  • 8. 8 Testing Anti-Pattern QA Team 30 manual testers 🧔🏼♂️🧔🏼♂️🧔🏼♂️🧔🏼♂️ 🧔🏼♂️🧔🏼♂️🧔🏼 🧔🏼♂️🧔🏼♂️🧔🏼♂️🧔🏼♂️🧔🏼♂️ ... 30% end-to-end coverage using GUI robots, Selenium,.. absent (old technology stack) scarce unit-tests, 10% coverage Ice-Cream Cone History of Testing: Reality in many Successful Monoliths today:
  • 9. 9 https://martinfowler.com/articles/practical-test-pyramid.html E2E Testing Pyramid Test a thin slice of behavior MOCKS Test a group of modules Test everything as whole ⭐️ Deep Edge Case ⭐️ Critical Business Flow (eg. checkout) overlapping is expected surface is proportional to quantity
  • 11. 11 Why we 💖 Mocks Isolated Tests from external systems Fast 👑 no framework, DB, external API Test Less Logic when testing high complexity 😵💫  Alternatives: - In-mem DB - Testcontainers 🐳 - WireMock, ..
  • 12. 12 public computePrices(...) { // A for (Product product : products) { +1 // B if (price == null) { +1 // C } for (Coupon coupon : customer.getCoupons()) { +1 if (coupon.autoApply() +1 && coupon.isApplicableFor(product, price) +1 && !usedCoupons.contains(coupon)) { +1 // D } } } return ...; } Code Complexity - Cyclomatic - Cognitive (Sonar)
  • 13. 13 Logic under test Testing Complex Code More execution paths through code => More tests Test Test Test Test Test Test Test complexity=5 =6 f(a) g(b) calls f() calling g() together have a complexity of up to ... Too Many (to cover all branches) Too Heavy (setup and input data) Tests for f() calling g() become... 30 Test Test Test Test Test Test Test Test Test Test Test Test
  • 15. 15 Why we 💖 Mocks Isolated Tests from external systems Fast 👑 no framework, DB, MQ, external API Test Less Logic when testing high complexity 😵💫  Alternatives: - In-mem DB (H2) - Testcontainers 🐳 - WireMock, .. 🤨 Cheating James Coplien in https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf
  • 16. 16 Why we 🤨 Mocks Uncaught Bugs in Production 😱 despite 1000s of ✅GREEN tests (lock, tap, doors, umbrella) Fragile Tests 💔 that break at any refactoring Unreadable Tests 😵💫 eg. a test using ≥ 5 mocks 
  • 18. 18
  • 19. 19 Test has 20 lines full of mocks 😵💫 😡 BURN THE TEST! bad cost/benefit ratio HONEYCOMB TESTS Prefer Integration/Social Tests WHAT AM I TESTING HERE ? syndrome Tested prod code has 4 lines 😩 f(..) { a = api.fetchB(repo1.find(..).getBId()); d = service.createD(a,b,repo2.find(..)); repo3.save(d); mq.send(d.id); } g(dto) { repo2.save(mapper.fromDto(dto, repo1.find(..))); } SIMPLIFY PRODUCTION "Remove Middle-Man" (inline method / collapse layer)
  • 21. 21 The Legacy Monolith can hide terrible complexity behind a few entry points  Cover deep corners of logic with Unit Tests Microservices have more APIs (stable test surfaces), hide less complexity (but more configuration risk)  Test more at API-level (Integration)  Honeycomb Testing Strategy
  • 22. 22 Integration (one microservice) Integrated (entire ecosystem) Deploy all microservices in dockers / staging env Expensive, slow, flaky tests Use for business-critical flows (eg checkout) Cover one microservice fully Use for: Default for every flow ⭐️⭐️⭐️ Isolate tests without mocks Cover 1 class/role (Solitary/Social Unit Tests) Use for: naturally isolated pieces with high complexity. @Mock are allowed Honeycomb Testing Strategy Testcontainers 🐳 WireMock &co Contract Tests (Pact, SCC) DB ES Kafka ... API many tests on one entry point https://engineering.atspotify.com/2018/01/testing-of-microservices/ Implementation Detail (a role) complexity decouple and test in isolation
  • 23. 23 Unit Tests give you most Design Feedback 💎 More Complexity => Better Design Implementation Detail Tests 👍 MOCKS complexity You can black-box-test horrible, terrible, unmaintainable code
  • 24. 24 The Dawn of Mocks (2004)
  • 25. 25 The Dawn of Mocks (2004) http://jmock.org/oopsla2004.pdf
  • 26. 26 BAD HABIT Mock Roles, not Objects http://jmock.org/oopsla2004.pdf You implement a new feature > ((click in UI/postman)) > It works > 🎉 Oh NO!! I forgot to write tests 😱 ...then you write unit tests blindly mocking all the dependencies of the prod code you wrote ↓ Few years later: "My tests are fragile and impede refactoring!" Contract-Driven Design Before mocking a dependency, clarify its responsibility = After you mock an API, it freezes ❄️ (changing it = pain) 😭
  • 27. 27 strive to write Social Unit Tests for components (groups of objects) with a clear responsibility ✅ Internal refactoring of the component won't break the tests ❌ More complexity to understand! More mocks to face? Instead of fine-grained Solitary Unit Tests testing one class in isolation, A B < >
  • 29. 29 "Unit Testing means mocking all dependencies of a class" - common belief "It's perfectly fine for unit tests to talk to databases and filesystems!"- Ian Cooper in TDD, Where Did It All Go Wrong Unit Testing = ? Robust Unit Testing requires identifying responsibilities #0
  • 30. 30 Unit Testing tells you to simplify signatures and data structures #1
  • 31. 31 var bigObj = new BigObj(); bigObj.setA(a); bugObj.setB(b); prod.method(bigObj); Tests must create bigObj just to pass two inputs🧔 method(bigObj) MUTABLE DATA 😱 in 2023? using only 2 of the 15 fields in bigObj method(a, b) Precise Signatures prod.method(a, b); Also, simpler tests: Pass only necessary data to functions ✅ when(bigObj.getA()).thenReturn(a); ⛔️ Don't Mock Getters ⛔️ prod.horror(new ABC(a, b, c)); horror(abc) Parameter Object class ABC {a,b,c} When testing highly complex logic, introduce a ⛔️ Don't return Mocks from Mocks ⛔️ (mockA) ✅ Mock behavior. ✅ Construct test data.
  • 32. 32 🏰 Constrained Objects = data structures that throw exceptions on invalid data Customer{email ≠ null}, Interval{start<end}  Mutable: Domain Entities, Aggregates  Immutable❤️: Value Objects
  • 33. 33 ❶ A Constrained Object gets Large ↓ Object Mother Pattern TestData.customer(): a valid Customer coupling Break Domain Entities InvoicingCustomer | ShippingCustomer in separate Bounded Contexts packages > modules > microservices ❷ Integration and Social Unit Tests❤️ require heavy data inputs * https://martinfowler.com/bliki/ObjectMother.html (2006) Same Object Mother used in different verticals invoicing | shipping ↓ Split Object Mother per vertical InvoicingTestData | ShippingTestData Creating valid test data gets cumbersome CREEPY A large class shared by many tests Don't change it: only add code (lines/methods). Each tests can tweak the objects for their case. ✅ TestData.musk(): Customer (a persona) 🏰
  • 34. 34 Object Mother to unmarshal JSONs from /src/test/resource 🧔
  • 35. 35 Tests require detailed understanding of: External API/DTOs The Library: to mock it dto = externalApi.call(apiDetails); ... dto.getFooField() ... Lib.use(mysteriousParam,...) Tests should speak your Domain Language #respect4tests Agnostic Domain Isolate complex logic from external world via Adapters obj = clientAdapter.call(domainStuff) ... myDomainObject.getMyField() ... libAdapter.use(😊) Your complex logic directly uses External API/DTOss or heavy libraries:
  • 36. 36 application / infra My DTOs External API External DTOs Clien t External System Application Service Simplified Onion Architecture (more in my "Clean Pragmatic Architecture" at Devoxx Ukraine 2021 on YouTube) Value Object Entity id Domain Service Domain Service agnostic domain Repo IAdapter Adapter ⛔️ ⛔️ IWrapper Ugly Library Domain Complexity Protected Inside
  • 37. 37 #1 Unit Testing encourages Minimal Signatures Tailored Data Structures Agnostic Domain
  • 38. 38 #2 Unit Testing tells you to break Highly Complex Logic
  • 39. 39 Any problem in computer science can be solved by introducing another level of abstraction. - David Wheeler (corrupted quote)
  • 40. 40 class BigService { f() { //complex g(); } g() { //complex } } Inside the same class, a complex function f() calls a complex g() g() grew complex => unit-test it alone? When testing f(), can I avoid entering g()? Can I mock a local method call? class HighLevel { LowLevel low; f() {//complex low.g(); } } class LowLevel { g() {/*complex*/} } ↓ Partial Mock (@Spy) Hard to understand tests: Which prod method is real, which is mocked? 🧔 Split by Layers of Abstraction (high-level policy vs low-level details) Only use it when testing Legacy Code If splitting the class breaks cohesion, test f() + g() together with social unit tests ⛔️
  • 41. 41 class HighLevel { LowLevel low; f() {//complex low.g(); } } Split by Layers of Abstraction = vertical split of a class class LowLevel { g() {/*complex*/} } horizontal  placeOrder(o) processPayment(o)
  • 42. 42 class Wide { A a; B b; //+more dependencies f() {..a.a()..} g() {..b.b()..} } @ExtendWith(MockitoExtension) class WideTest { @Mock A a; @Mock B b; @InjectMocks Wide wide; // 5 tests for f() // 7 tests for g() } ↓ Split the test class in WideFTest, WideGTest (rule: the fixture should be used by all tests) Unrelated complex methods in the same class use different sets of dependencies: class ComplexF { A a; f() { ..a.a().. } } class ComplexG { B b; g() { ..b.b().. } } @BeforeEach void sharedFixture() { when(a.a()).then... when(b.b()).then... } Split Unrelated Complexity Part of the setup is NOT used by a test. ** Mockito (since v2.0) throws UnnecessaryStubbingException if a when..then is not used by a @Test, when using MockitoExtension  Unmaintainable Tests 🧔 FIXTURE CREEP = test setup DRY https://www.davidvlijmincx.com/posts/setting_the_strictness_for_mockito_mocks/ use
  • 43. 43 Split Unrelated Complexity class ComplexF { A a; f() { ..a.a().. } } class ComplexG { B b; g() { ..b.b().. } } horizontally ↔️ getProduct() createProduct()
  • 44. 44 Vertical Slice Architecture (VSA) https://jimmybogard.com/vertical-slice-architecture/ class GetProductUseCase { @GetMapping("product/{id}") GetResponse get(id) { ... } } horizontally ↔️ Organize code by use-cases, not by layers class CreateProductUseCase { @PostMapping("product/{id}") void create(CreateRequest) { ... } }
  • 45. 45 vertically ↕️ Tests help us to break complexity horizontally ↔️ #2 clear roles by
  • 46. 46 Should I mock it? – Practical Examples in a Spring app Repository (eg Spring Data JpaRepository)? ✅YES: clear responsibility with stable API + expensive to integration test Message Sender (eg RabbitTemplate)? ✅YES: clear responsibility, simple API + expensive to integration-test Flexible library class (RestTemplate/WebClient) ? ❌NO: complex API  Integration Test with WireMock? Adapter wrapping an external API call ? ✅YES: allow to keep your tests agnostic Satellite class (simple DtoEntity mapper) ? ❌NO: too simple  Social / Integration Test A logic component (@Service) ? ✅YES: if clear, non-trivial responsibility: NotificationService, UpdateProductStockService ❌NO if unclear role: ProductService doing "anything"  Social/Integration Test A Data Structure (@Entity/@Document/Dto/...) ? ❌ don't mock  populate an instance
  • 47. 47 #3 Unit Testing promotes Functional Programming values Pure Functions & Immutable Objects
  • 48. 48 VictorRentea.ro a training by No Side-Effects (causes no changes) INSERT, POST, send message, field changes, files Same Input => Same Output (no external source of data) GET, SELECT, time, random, UUID … Pure Functions just calculates a value aka Referential Transparent
  • 49. 49 No Network or files No Changes to Data No time or random Pure Functions (When using a DI container)
  • 50. 50 @VisibleForTesting a = repo1.findById(..) b = repo2.findById(..) c = api.call(..) 🤯complexity🤯 repo3.save(d); mq.send(d.id); Complex logic using many dependencies (eg: computePrice, applyDiscounts) Many tests using lots of mocks when(..).thenReturn(a); when(..).thenReturn(b); when(..).thenReturn(c); prod.complexAndCoupled(); verify(..).save(captor); d = captor.get(); assertThat(d)... verify(..).send(...); ✅ Simpler tests (less mocks) d = prod.pure(a,b,c); assertThat(d)... Reduce Coupling of Complex Logic Clarify inputs/outputs D pure(a,b,c) { 🤯complexity🤯 return d; } extract method
  • 51. 51 © VictorRentea.ro a training by Complexity State Mutation DB Imperative Shell API call Files Complex Logic Functional Core
  • 52. 52 © VictorRentea.ro a training by Complexity State Mutation DB API call Files Complex Logic / Segregation Imperative Shell Functional Core
  • 53. 53 © VictorRentea.ro a training by Functional Core Imperative Shell Extract heaviest complexity as pure functions / Segregation Imperative Shell Functional Core
  • 54. 54 © VictorRentea.ro a training by Immutable Objects =objects you can't modify after instantiation - read-only fields: final, @lombok.Value, record - referencing immutable objects: mind the collections! To change them > produce a modified copy
  • 55. 55 method(Mutable order, discounts) { ds.applyDiscounts(order, discounts); var price = cs.computePrice(order); return price; } ... but you use mutable objects bugs in production ❌ despite 4000 ✅ tests You have 4.000 unit tests, 100% test coverage 😲 👏 ↓ Paranoid Testing (InOrder can verify method call order) Immutable Objects method(Immutable order, d) { var discountedOrder = ds.applyDiscounts(order, d); var price = cs.computePrice(discountedOrder); return price; } TEMPORAL COUPLING compilation fails ❌ If you swap two lines ... If you swap two lines ...
  • 56. 56 1. Collapse Middle-Man vs "What am I testing here?" Syndrome or bigger tests: 2. Honeycomb Testing Strategy = more Integration Tests over Fragile Unit Tests 3. Precise Signatures: simpler arguments, better names 4. Dedicated Data Structures vs Creepy Object Mother 5. Agnostic Domain vs mixing core logic with External-APIs or Heavy-Library calls 6. Split Complexity by Layers of Abstraction ↕️ vs Partial Mocks (aka spy) 7. Split Unrelated Complexity ↔️ vs Fixture Creep (large shared setup) 8. Clarify Roles, Social Unit Tests vs blindly mock all dependencies 9. Decouple Complexity in Pure Functions vs Many tests full of mocks 10.Immutable Objects vs Temporal Coupling Design Hints from Tests
  • 58. 58 timeframe for developing your feature When do you start writing tests? ✅ understand the problem ✅ early design feedback 💎 💎 💎 ✅ confidence to refactor later Too Late TDD Early Enough
  • 59. Writing unit tests early increases friction with careless design
  • 60. 60 Unit Testing Reading Guide 1] Classic TDD⭐️⭐️⭐️ (mock-less) https://www.amazon.com/Test-Driven-Development-Kent-Beck Mock Roles, not Objects ⭐️⭐️⭐️: http://jmock.org/oopsla2004.pdf "Is TDD Dead?" https://martinfowler.com/articles/is-tdd-dead/ Why Most Unit Testing is Waste (James Coplien): https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf vs Integrated Tests are a Scam(J Brains): https://blog.thecodewhisperer.com/permalink/integrated-tests-are-a-scam 2] London TDD⭐️⭐️⭐️ (mockist) https://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests + Demo Exercise by Sandro Mancuso https://www.youtube.com/watch?v=XHnuMjah6ps 3] Patterns⭐️ https://www.amazon.com/Art-Unit-Testing-examples 4] https://www.amazon.com/xUnit-Test-Patterns-Refactoring-Code 5] (skip through) https://www.amazon.com/Unit-Testing-Principles-Practices-Patterns
  • 61. Test-Driven Design Insights Article: https://victorrentea.ro/blog/design-insights-from-unit-testing/ Code: https://github.com/victorrentea/unit-testing.git on branch: devoxx-be-2023 About Victor Rentea: https://victorrentea.ro Stay connected. Join us:

Hinweis der Redaktion

  1. I'm victor rentea from Romania. I'm a java champion, working in our field for 17 years. 8 years ago I realized coding was not enough for me, and I started looking around to help the others. Today this has become my full-time job: training and consultancy for companies throughout Europe. My favorite topics are ... but of course, to talk about these topics you have to master the frameworks you use, so I do intense workshops on Spring Framework, .... More senior groups often call me for performance tuning or secure coding. If you want to know more, you can find there my full training offer Besides the talks at different conferences that you can find online, I try to to one webinar each month for my community. A few years ago I started this group on meetup to have where to share my ideas and learn from the others in turn. - This community has exceeded my wildest dreams, turning into one of the largest communities in the world on Software Craftsmanship. - So what happens there? One day a month we have a zoom online webinar of 1-2 hours after work, during which we discuss one topic and then debate various questions from the participants – usually we have close to 100 live participants, so it's very engaging. If you want to be part of the fun, DO join us, it's completely free. - Many past events are available on my youtube channel. - Outside of work, I have 2 kids and a cat that wakes us up in the middle of the night.