presentatie tdd venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 sogyo 5 edwin van dillen...

11
1 1 1 © 1995-2007 Sogyo Test-Driven Development Test-Driven Development Edwin van Dillen [email protected] Thomas Zeeman [email protected] 2 © 1995-2007 Sogyo Agenda Agenda About Sogyo Why test? Context of Test-Driven Development Test-Driven Development in theory …and in practice Pro’s / con’s Beyond Test-Driven Development

Upload: others

Post on 24-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

1

1

1© 1995-2007 Sogyo

Test-Driven DevelopmentTest-Driven Development

Edwin van [email protected]

Thomas [email protected]

2© 1995-2007 Sogyo

AgendaAgenda

� About Sogyo

� Why test?

� Context of Test-Driven Development

� Test-Driven Development in theory

� …and in practice

� Pro’s / con’s

� Beyond Test-Driven Development

Page 2: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

2

3© 1995-2007 Sogyo

4© 1995-2007 Sogyo

About Sogyo …About Sogyo …

Competence areas:

• Software Engineering

• Software Architecture

• Enterprise Application Integration (EAI)

• Application Management

Page 3: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

3

5© 1995-2007 Sogyo

Edwin van Dillen Edwin van Dillen

� 1997 – 2000: Engineer @ SOGYO

� Projects: Nationale Nederlanden, ING Groep, ABN AMRO, Hypotheekshop;

� 2000 – 2003: Consultant @ CIBIT

� Consultancy for a.o. Postbank, ING Bank ANVA, Prismant

� Teacher Masterclasses and MSc forr a.o. Fortis ASR, Unive, ABN AMRO, Centraal Beheer/Achema, etc.

� 2003 – 2007: Principal Consultant @SOGYO

� Responsible for technical direction of company;

� Active as consultant, teacher/host, coach.

Edwin van Dillen | [email protected] | m. 06 22 50 62 33

6© 1995-2007 Sogyo

Thomas Zeeman Thomas Zeeman

� 2003 – 2005: Engineer @ SOGYO

� Projects: a.o. Friesland Coberco, ABN AMRO, ANVA;

� 2006– 2007: Consultant @ SOGYO

� Consultancy for a.o. FinansBank, Contracto;

� Active as consultant, teacher/host, senior engineer.

Thomas Zeeman | [email protected]

Page 4: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

4

7© 1995-2007 Sogyo

But first a test…But first a test…

� Sort this list:

� C

� C++

� Perl

� Java

� Ruby

� Python

8© 1995-2007 Sogyo

Why testWhy test

� 1997: The Y2K-bug starts to appear

� 2000: New Year’s Eve, Y2K-bug still lingers…

Page 5: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

5

9© 1995-2007 Sogyo

V-modelV-model

10© 1995-2007 Sogyo

History of TDDHistory of TDD

� Originally described in Kent Beck’s book “Test-Driven Development” from 2003

� Originated within eXtreme Programming movement

� Now stands on its own feet

� Heavy use of the xUnit framework.

Page 6: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

6

11© 1995-2007 Sogyo

Test-Driven Development: theoryTest-Driven Development: theory

� Mantra:

� “Test first, code later”

� “Red, green, refactor, repeat”

� Really needs an incremental process.

� Leans heavily on refactoring.

12

12© 1995-2007 Sogyo

DemoDemo

Or: how to write Fibonacci the TDD way

Page 7: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

7

13© 1995-2007 Sogyo

And now for some realityAnd now for some reality

� In practice, the mantra goes:

� code some, test some

� Unit tests are abused for integration tests

� Either between units

� Or between app and dependencies like the DB

� Unit tests are abused for performance tests

14

14© 1995-2007 Sogyo

Demo 2Demo 2

Or: a more real life example

Page 8: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

8

15© 1995-2007 Sogyo

Pro’s & Con’sPro’s & Con’s

� Pro’s:

� More to the point

� Less coupling

� Documentation

� Future maintenance

� Con’s

� All green does not mean zero bugs!

� GUIs can’t be tested with proper TDD.

� Persistent data

� Future maintenance

16© 1995-2007 Sogyo

Hard Topics of TDDHard Topics of TDD

� When unit testing turns into integration testing

� When do you have enough tests

� Text fixtures, esp. when using a database

� Duration of a test run

Page 9: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

9

17© 1995-2007 Sogyo

Advanced TDDAdvanced TDD

� Mocks vs Stubs

� xUnit family:

� dbUnit

� jUnitPerf

� httpUnit

� …

18© 1995-2007 Sogyo

Beyond TDDBeyond TDD

� Continuous integration

� Code Coverage

� Jester / Pester / Nester

Page 10: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

10

19© 1995-2007 Sogyo

SummarySummary

� Knowledge of refactoring is a must

� Produces a set of regression tests

� Increases confidence in the end product

� Side effect:

� More code, but shorter development time

20© 1995-2007 Sogyo

Next session…Next session…

� Domain Driven Design: a case with Lego Mindstorms

� Who: Edwin van Dillen

� When: 21st of March

� Time: 09:30

Page 11: Presentatie TDD Venlo - colloquium.fontysvenlo.org€¦ · 3 ©1995-2007 Sogyo 5 Edwin van Dillen 1997 – 2000: Engineer @ SOGYO Projects: Nationale Nederlanden, ING Groep, ABN AMRO,

11

21© 1995-2007 Sogyo

ResourcesResources

� Test-Driven Development by Example, Kent Beck, Addison-Wesley

� Applying Domain-Driven Design and Patterns, Jimmy Nilsson, Addison-Wesley

� http://www.martinfowler.com/articles/mocksArentStubs.html

� http://www.martinfowler.com/articles/continuousIntegration.html

� http://www.xprogramming.org