Unit vs. Integration Tests
-
Upload
david-voelkel -
Category
Software
-
view
177 -
download
1
Transcript of Unit vs. Integration Tests
Unit vs. Integration Tests
Softwerkskammer Meetup Munich
@codecentric
18.06.2015
David Völkel
@davidvoelkel
Agenda
● Theory ● Unit vs. Integration Tests
● Test Pyramid
● How to achieve it
● Workshop ● What works well in our projects?
● Hardest challenges?
● How to address them?
● Another beer
Expensive Integrated Tests
Isolated
Integrated
Creation &
Maintenance
cheap expensive
Feedback fast slow
Finding Errors easy difficult
Fragility minimal high
Significance for User medium high 4
http://www.jeasyui.com/tutorial/app/crud.php
n
+
m
n
*
m
Unit under test?
Isolated
Integrated
Strengths Complex logic
(„combinatorial
explosion“),
conditionals, breadth
Integration, data
flow, depth
Business Dimension
Acceptance Tests == UI-Tests?
Inspired through "the testing iceberg“ by Seb Rose / Matt Wynne
Acceptance Tests
Technical Tests
Business Domain
De
gre
e o
f In
teg
ratio
n .
Example Email Validation
N x integrated web tests
Input Output
„[email protected]“ „Email OK“
„mail.without@tld“ „Email invalid“
„mail.without.at.de“ „Email invalid“
„@without-user.de“ „Email invalid“
…
valid
Example Email Validation
1 x integrated web tests
N x isolated tests
valid
Input Output
„[email protected]“ „Email OK“
„mail.without@tld“ „Email invalid“
„mail.without.at.de“ „Email invalid“
„@without-user.de“ „Email invalid“
…
(UI) End2End Tests
Fully integrated down to the backend
for
• backend interaction
• few logic (CRUD)
• simple workflows
• hardly testable legacy
UI
E2E
Compo nent
Unit
15
Back-
end
UI-Layer
component test
● testability required ● fat client
● SPA + REST
● server-side rendering?
E2E
Compo nent
Unit
UI
Mock
Back
end
UI-Layer
for • session status
• complex UI workflows
• workflows with few backend-
interaktion
E2E
Compo nent
Unit
UI
Mock
Back
end
UI Unit Tests
for complex logic
value rendering
MVP: Presenter logic
Address example:
„D-80687, München, Elsenheimerstraße 55a“
„-, München, Elsenheimerstraße 55a“?
E2E
Compo nent
Unit
UI
Resumee
UI
Service
Unit
Test Pyramid
• Integrated Tests: Integration & Depth
• Isolierte Tests: Logic & Breadth
Orthogonal Decomposition
• Split up Acceptance Tests
• Business Rules
• UI
• E2E, UI Layer, UI Unit Tests
Workshop Agenda
● Round 1: current state in your project ● Successful solutions?
● Hardest challenges?
● Show & tell
● Round 2 ● how can we improve?
● Show & tell
● Retrospective