Download presentation
Presentation is loading. Please wait.
Published byTianna Grater Modified over 10 years ago
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 Driven Development) ? Lets practice it together doing a kata... Pierre-Emmanuel DAUTREPPE – October 26th 2012
2
2 «.NET Architect » and « XP Coach » Founder of User Group « DotNetHub » « La Journée Agile »/« Agile Tour Namur » Me contacter via : pierre@dotnethub.be http://www.pedautreppe.com http://www.dotnethub.be @pedautreppe Pierre-Emmanuel DAUTREPPE
3
3 Our developer life We are genious ! (generally misunderstood) We = developers That functionality you implemented, you have ? No, thats useless ! Its trivial ! … … … doesnt work … ???? n00b documented it commented it tested it Turk et De Groot
4
4 Our developer life
5
5 Pinder Circus Just use a safety net !
6
6 Tests are a validation tool…
7
7 …but also a documentation tool… Here is a pretty clear user manual Its written « Sort out your own problems ! »
8
8 …and a design tool
9
9 The « Test Driven Development » Cycle Refactoring Test passes Implement Test compiles but fail Write needed API It does not compile Write a test Refactoring of tests Refactoring of code
10
10 string ReadFooValue() { string[] lines = File.ReadAllLines(@"c:\myapp.ini"); foreach ( var line in lines ) { int index = line.IndexOf('='); string name = line.Substring(0, index); if ( name.StartsWith("Foo") ) { string value = line.Substring(index + 1); return value; } return null; } string ReadFooValue() { string[] lines = File.ReadAllLines(@"c:\myapp.ini"); foreach ( var line in lines ) { int index = line.IndexOf('='); string name = line.Substring(0, index); if ( name.StartsWith("Foo") ) { string value = line.Substring(index + 1); return value; } return null; } Code coverage, myth or reality ? « Complexity » and « code coverage »… whats that ?
11
11 Code coverage, myth or reality ? 100% code coverage is not enough ! Phil Haack
12
12 Development Test Release Improve the feedback
13
13
14
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)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.