Top Banner
Unit vs. Integration Tests Softwerkskammer Meetup Munich @codecentric 18.06.2015 David Völkel @davidvoelkel
25

Unit vs. Integration Tests

Aug 04, 2015

Download

Software

David Völkel
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unit vs. Integration Tests

Unit vs. Integration Tests

Softwerkskammer Meetup Munich

@codecentric

18.06.2015

David Völkel

@davidvoelkel

Page 2: Unit vs. Integration Tests

Unit vs. Integrated Tests

Isolated

integrated vs.

Page 3: Unit vs. Integration Tests

Which do you prefer?

Isolated Integrated

1 2 3 4 5

Page 4: Unit vs. Integration Tests

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

Page 5: Unit vs. Integration Tests

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

Page 6: Unit vs. Integration Tests

Unit under test?

Isolated

Integrated

Strengths Complex logic

(„combinatorial

explosion“),

conditionals, breadth

Integration, data

flow, depth

Page 7: Unit vs. Integration Tests

Test Pyramid

UI

Service

Unit

De

gre

e o

f In

tegra

tio

n

By Mike Cohn

Page 8: Unit vs. Integration Tests

No: Test Pyramids!?!

By Mike Cohn

Page 9: Unit vs. Integration Tests

?

?

Unit

Page 10: Unit vs. Integration Tests

Orthogonal decomposition

By Mike Cohn

. Inte

gra

ted

Tests

Isolated Tests &

Page 11: Unit vs. Integration Tests

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 .

Page 12: Unit vs. Integration Tests

Split up Acceptance Tests

Acceptance Tests

UI Domain Rules

Page 13: Unit vs. Integration Tests

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

Page 14: Unit vs. Integration Tests

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“

Page 15: Unit vs. Integration Tests

UI Test Pyramid

UI Test !=

End2End Tests

E2E

Compo

nent

Unit

De

gre

e o

f In

tegra

tio

n

Page 16: Unit vs. Integration Tests

(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

Page 17: Unit vs. Integration Tests

Gmail Example

E2E

Compo nent

Unit

Minimal workflow

Page 18: Unit vs. Integration Tests

UI-Layer

component test

● testability required ● fat client

● SPA + REST

● server-side rendering?

E2E

Compo nent

Unit

UI

Mock

Back

end

Page 19: Unit vs. Integration Tests

UI-Layer

for • session status

• complex UI workflows

• workflows with few backend-

interaktion

E2E

Compo nent

Unit

UI

Mock

Back

end

Page 20: Unit vs. Integration Tests

Gmail Example

E2E

Compo nent

Unit

Mail editing

Page 21: Unit vs. Integration Tests

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

Page 22: Unit vs. Integration Tests

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

Page 23: Unit vs. Integration 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

Page 24: Unit vs. Integration Tests

Retrospective

Page 25: Unit vs. Integration Tests

License

Creative Commons Attribution-ShareAlike 3.0

https://creativecommons.org/licenses/by-sa/3.0/de/