Test-Driven Development. As it should be. Jarno Keskikangas Project Manager Digia Plc 1 2007 SYSOPENDIGIA Plc
Outline Me, You and the Company Agile software development in general and TDD in particular Test-Driven Development in a nutshell Lessons learnt & summary Q & A 2 2007 SYSOPENDIGIA Plc
Me, You and the Company 3 2007 SYSOPENDIGIA Plc
Me Agile advocate practitioner rather than researcher focus on the bottom line Introducing and implementing TDD practices to own organization and other entities Currently working as a scrum master and project manager...with software developer background 4 2007 SYSOPENDIGIA Plc
You Familiar with agile principles Comfortable with xunit frameworks Have heard or tried TDD Will have the time of your life during the presentation In a way or other =) 5 2007 SYSOPENDIGIA Plc
...and the Company, Outline Digia Plc Modern and agile software house Complete solution offering Business critical ICT solutions Forerunner in mobile and wireless solutions Focused market segments Telecommunications Industry and Trade Finance and Services Listed on the Nordic Exchange Headquarters in Helsinki, offices in Estonia, Sweden and other locations in Finland Pro forma turnover in 2006 EUR 98.9 million Employs over 1100 professionals 6 2007 SYSOPENDIGIA Plc
Telecommunications Division Agile partner creating mobile software development services and solutions Trusted player providing business process improvement, integration and systems development Innovative forerunner building ICT solutions utilising mobile opportunities Employing over 550 professionals Handset Industry Integrating Innovations Operators & Media Corporations 7 2007 SYSOPENDIGIA Plc
Agile software development in general and TDD in particular 8 2007 SYSOPENDIGIA Plc
Agile Software Development Iterative and incremental development Close collaboration between business people and programmers Empowered and selforganized teams Working software as the primary measure of progress Risk Cost of change Agile project Waterfall project Time Time 9 2007 SYSOPENDIGIA Plc
Test-Driven Development. As it should be.
Test Driven Development Add a test Specification [Pass] Run the tests [Fail] Design Make a little change Development [Fail] Run the tests [Pass, Development continues] Testing [Pass, Development stops] 11 2007 SYSOPENDIGIA Plc
How to write good TDD specifications? What s the next most important thing the system doesn t do? Template for TDD scenarios Given some initial context (the givens) When an event occurs Then ensure some outcomes 12 2007 SYSOPENDIGIA Plc
Emerging design and mock objects Test class Domain object Test class Mock object Domain object Mock object 13 2007 SYSOPENDIGIA Plc
To see is to believe
EUnit Test Creation Wizards /* ----------------------------------------------------------------------------- This file has been generated with EUnit Pro http://www.sysopendigia.com/qualitykit ----------------------------------------------------------------------------- */ #ifndef CMYTRIANGLE_TESTI_H #define CMYTRIANGLE_TESTI_H // INCLUDES #include <CEUnitTestSuiteClass.h< CEUnitTestSuiteClass.h> #include <EUnitDecorators.h< EUnitDecorators.h> #include "CMyTriangle.h" CMyTriangle.h" // FORWARD DECLARATIONS // CLASS DEFINITION /** * Generated EUnit test suite class. */ NONSHARABLE_CLASS( CMyTriangle_Testi ) : public CEUnitTestSuiteClass { public: // Constructors and destructor static CMyTriangle_Testi* NewL(); static CMyTriangle_Testi* NewLC(); ~CMyTriangle_Testi(); private: // Constructors CMyTriangle_Testi(); void ConstructL(); private: // New methods void SetupL(); void Teardown(); void T_Global_AreaL(); void T_Global_CMyTriangleL(); void T_Global_CenterL(); void T_Global_CrossProductL(); void T_Global_FirstCornerL();
EUnit Test Execution EUnit S60 Gui EUnitExeRunner Connectivity Carbide.C++ EUnit View Device Test Manager RPM server and device pool
Lessons learnt
Developer questionnaire 1. Facilitates better requirements 2. Reduces debugging effort 3. Reduces development time 4. Yields higher code quality 5. Promotes simpler design 6. Is noticeably effective 7. Getting into TDD mindset 8. Lack of upfront design is a hindrance Question 1 2 3 4 5 6 7 8 0 1 2 3 4 5 Mean Standard Deviation 18 2007 SYSOPENDIGIA Plc
Testimonials 3. Jos voit valita vapaasti, käytätkö mieluummin TDD-tekniikkaa vai jotain muuta lähestymistapaa? Miksi? Ehdottomasti TDD. Mikäli unit testejä tehdään jollain muulla keinolla ne eivät yleensä osu ongelman ytimeen vaan harrastetaan koodikattavuuden generointia esim. Tarkistelemalla raja-arvoja. Mielellään TDD:tä, koska silloin automaattisesti päädytään testattavaan ja yleensä toimivaan designiin. Koodin laatu pysyy koko kehitystyön ajan hyvänä. 2. Kuvaile kohtaamiasi ongelmia TDD-tekniikan soveltamisessa. Miten ongelmia voisi mielestäsi vähentää? Suurimmat ongelmat syntyvät vanhojen partojen pinttyneistä tavoista suunnitella kaikki etukäteen eli ei anneta TDD:n tehdä sitä mihin se on tarkoitettu. Huono design: konkreettiset riippuvuudet, sykliset riippuvuudet, luokilla monta vastuuta. Luokat pitäisi suunnitella niin, että ne voidaan yksikkötestata. 19 2007 SYSOPENDIGIA Plc
Summary
TDD is not about testing. It s about specification, design and testing.
TDD is essential element of agile software engineering.
Agile software engineering is harder to adopt than agile project management.
Pay now or pay later. The later you pay, the higher the K.
Testimonials Thank You! jarno.keskikangas@digia.com www.digia.com 25 2007 SYSOPENDIGIA Plc
References http://blog.daveastels.com/files/bdd_intro.pdf Scott Ambler: Introduction to Test Driven Design http://www.agiledata.org/essays/tdd.html Dan North: Introducing BDD http://dannorth.net/introducing-bdd/ Boby Georgea, Laurie Williams: A structured experiment of test-driven development Dozens of research papers, see ACM and IEEE electronic libraries 26 2007 SYSOPENDIGIA Plc