TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together...

11
TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Let’s practice it together doing a kata... Pierre-Emmanuel DAUTREPPE – October 26th 2012

Transcript of TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together...

Page 1: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

TDD by example

Why shall we test ?What is TDD (Test Driven Development) ?Let’s practice it together doing a kata...

Pierre-Emmanuel DAUTREPPE – October 26th 2012

Page 2: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

2

« .NET Architect » and « XP Coach »

Founder of

User Group « DotNetHub »

« La Journée Agile »/« Agile Tour Namur »

Me contacter via :

[email protected]

http://www.pedautreppe.com

http://www.dotnethub.be

@pedautreppe

Pierre-Emmanuel DAUTREPPE

Page 3: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

3

Our developer life

We are genious ! (generally misunderstood)

We = developers

That functionality you implemented, you have ? No, that’s useless ! It’s trivial ! … … … doesn’t work … ????

n00b

documented itcommented it

tested it

Turk et De Groot

Page 4: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

4

Our developer life

Page 5: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

5

Our developer life

Pinder CircusJust use a safety net !

Page 6: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

6

Tests are a validation tool…

Page 7: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

7

…but also a documentation tool…

Here is a pretty clear user manual

It’s written « Sort out your own

problems ! »

Page 8: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

8

…and a design tool

Page 9: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

9

The « Test Driven Development » Cycle

Refactoring

Test passes

Implement Test compiles but fail

Write needed API

It does not compile

Write a testRef

acto

ring

of te

sts

Refac

torin

g

of c

ode

Page 10: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

13

Page 11: TDD by example Why shall we test ? What is TDD (Test Driven Development) ? Lets practice it together doing a kata... Why shall we test ? What is TDD (Test.

14

Conclusion

TDD let you use tests as A validation tool A documentation tool A design tool

Follow the TDD rules Be iterative: split your work in small (requirement)

increments Always start by writing a test Then implement untill the test passes And Cleanup! (refactor)