Transcript
Page 1: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

1 ©2007 SYSOPENDIGIA Plc

Test-Driven Development.As it should be.

Jarno Keskikangas

Project Manager

Digia Plc

Page 2: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

2 ©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

Page 3: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

3 ©2007 SYSOPENDIGIA Plc

Me, You and the Company

Page 4: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

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 projectmanager

• ...with software developer background

4 ©2007 SYSOPENDIGIA Plc

Page 5: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

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

Page 6: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

6 ©2007 SYSOPENDIGIA Plc

Outline...and the Company, 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

Page 7: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

7 ©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

Operators&

Media

Corporations

Integrating Innovations

Page 8: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

8 ©2007 SYSOPENDIGIA Plc

Agile software development in general and TDD in particular

Page 9: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

9 ©2007 SYSOPENDIGIA Plc

Agile Software Development

• Iterative and incremental development

• Close collaboration between business people and programmers

• Empowered and self-organized teams

• Working software as the primary measure of progress

Time

Risk

Agile project

Waterfall project

Time

Cost of change

Page 10: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

Test-Driven Development. As it should be.

Page 11: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

11 ©2007 SYSOPENDIGIA Plc

Test Driven Development

Run

the tests

Make a little

change

Add a test

Run

the tests

[Pass]

[Fail]

[Fail] [Pass, Development continues]

[Pass, Development stops]

Specification

Design

Development

Testing

Page 12: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

12 ©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

Page 13: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

13 ©2007 SYSOPENDIGIA Plc

Emerging design and mock objects

Test class

Domain object

Mock object

Test class

Domain object

Mock object

Page 14: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

To see is to believe

Page 15: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

EUnit Test Creation Wizards/*/*

----------------------------------------------------------------------------------------------------------------------------------------------------------

This file has been generated with This file has been generated with EUnitEUnit ProPro

http://http://www.sysopendigia.com/qualitykitwww.sysopendigia.com/qualitykit

----------------------------------------------------------------------------------------------------------------------------------------------------------

*/*/

##ifndefifndef __CMYTRIANGLE_TESTI_H____CMYTRIANGLE_TESTI_H__

#define __CMYTRIANGLE_TESTI_H__#define __CMYTRIANGLE_TESTI_H__

// INCLUDES// INCLUDES

#include <#include <CEUnitTestSuiteClass.hCEUnitTestSuiteClass.h>>

#include <#include <EUnitDecorators.hEUnitDecorators.h>>

#include "#include "CMyTriangle.hCMyTriangle.h""

// FORWARD DECLARATIONS// FORWARD DECLARATIONS

// CLASS DEFINITION// CLASS DEFINITION

/**/**

* Generated * Generated EUnitEUnit test suite class.test suite class.

*/*/

NONSHARABLE_CLASS( NONSHARABLE_CLASS( CMyTriangle_TestiCMyTriangle_Testi ))

: public : public CEUnitTestSuiteClassCEUnitTestSuiteClass

{{

public: // Constructors and destructorpublic: // Constructors and destructor

static static CMyTriangle_TestiCMyTriangle_Testi* * NewLNewL();();

static static CMyTriangle_TestiCMyTriangle_Testi* * NewLCNewLC();();

~~CMyTriangle_TestiCMyTriangle_Testi();();

private: // Constructorsprivate: // Constructors

CMyTriangle_TestiCMyTriangle_Testi();();

void void ConstructLConstructL();();

private: // New methodsprivate: // New methods

void void SetupLSetupL();();

void Teardown();void Teardown();

void void T_Global_AreaLT_Global_AreaL();();

void void T_Global_CMyTriangleLT_Global_CMyTriangleL();();

void void T_Global_CenterLT_Global_CenterL();();

void void T_Global_CrossProductLT_Global_CrossProductL();();

void void T_Global_FirstCornerLT_Global_FirstCornerL();();

Page 16: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

EUnit Test ExecutionEUnitEUnit S60 S60 GuiGui

ConnectivityConnectivity

DeviceDevice

RPM RPM serverserver and and devicedevice poolpool

EUnitExeRunnerEUnitExeRunner

Carbide.CCarbide.C++ ++ EUnitEUnit ViewView

TestTest ManagerManager

Page 17: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

Lessons learnt

Page 18: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

18 ©2007 SYSOPENDIGIA Plc

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

0 1 2 3 4 5

1

2

3

4

5

6

7

8

Qu

esti

on

Mean Standard Deviation

Page 19: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

19 ©2007 SYSOPENDIGIA Plc

Testimonials

• 3. Jos voit valita vapaasti, käytätkö mieluummin TDD-tekniikkaa vaijotain muuta lähestymistapaa? Miksi?

“Ehdottomasti TDD. Mikäli unit testejä tehdään jollain muulla keinolla neeivät yleensä osu ongelman ytimeen vaan harrastetaan koodikattavuudengenerointia esim. Tarkistelemalla raja-arvoja.”

“Mielellään TDD:tä, koska silloin automaattisesti päädytään testattavaan jayleensä toimivaan designiin. Koodin laatu pysyy koko kehitystyön ajanhyvänä.”

• 2. Kuvaile kohtaamiasi ongelmia TDD-tekniikan soveltamisessa. Miten ongelmia voisi mielestäsi vähentää?

“Suurimmat ongelmat syntyvät vanhojen partojen pinttyneistä tavoistasuunnitella kaikki etukäteen eli ei anneta TDD:n tehdä sitä mihin se on tarkoitettu.”

“Huono design: konkreettiset riippuvuudet, sykliset riippuvuudet, luokillamonta vastuuta. Luokat pitäisi suunnitella niin, että ne voidaanyksikkötestata.”

Page 20: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

Summary

Page 21: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

TDD is not about testing. It’sabout specification, design and

testing.

Page 22: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

TDD is essential element of agilesoftware engineering.

Page 23: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

Agile software engineeringis harder to adopt than

agile project management.

Page 24: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

Pay now or pay later. The lateryou pay, the higher the K.

Page 25: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

25 ©2007 SYSOPENDIGIA Plc

Testimonials

[email protected]

Thank You!

Page 26: Test-Driven Development. As itshouldbe. · Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

26 ©2007 SYSOPENDIGIA Plc

References

• http://blog.daveastels.com/files/BDD_Intro.pdf

• Scott Ambler: Introduction to Test Driven Designhttp://www.agiledata.org/essays/tdd.html

• Dan North: Introducing BDDhttp://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


Top Related