Click here to load reader

Test-Driven Development. As · PDF file Test Driven Development Run the tests Make a little change Add a test Run the tests [Pass] [Fail] [Fail] [Pass, Development continues] [Pass,

  • View
    0

  • Download
    0

Embed Size (px)

Text of Test-Driven Development. As · PDF file Test Driven Development Run the tests Make a little...

  • 1 ©2007 SYSOPENDIGIA Plc

    Test-Driven Development. As it should be.

    Jarno Keskikangas

    Project Manager

    Digia Plc

  • 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

  • 3 ©2007 SYSOPENDIGIA Plc

    Me, You and the Company

  • 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

  • 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

  • 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

  • 8 ©2007 SYSOPENDIGIA Plc

    Agile software development in general and TDD in particular

  • 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

    R is k

    Agile project

    Waterfall project

    Time

    C o s t o f c h a n g e

  • Test-Driven Development. As it should be.

  • 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

  • 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

  • 13 ©2007 SYSOPENDIGIA Plc

    Emerging design and mock objects

    Test class

    Domain object

    Mock object

    Test class

    Domain object

    Mock object

  • To see is to believe

  • 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

    #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();();

  • EUnit Test Execution EUnitEUnit S60 S60 GuiGui

    ConnectivityConnectivity

    DeviceDevice

    RPM RPM serverserver and and devicedevice poolpool

    EUnitExeRunnerEUnitExeRunner

    Carbide.CCarbide.C++ ++ EUnitEUnit ViewView

    TestTest ManagerManager

  • Lessons learnt

  • 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

    Q u

    e s ti

    o n

    Mean Standard Deviation

  • 19 ©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.”

  • 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.

  • 25 ©2007 SYSOPENDIGIA Plc

    Testimonials

    [email protected] www.digia.com

    Thank You!

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