SlideShare uma empresa Scribd logo
1 de 36
What is Test-Driven Development?
        A Primer on
        Testable Specifications…
Develop
Traditional Testing               Test Scripts
Approach

                                  Error Found!

 Requirements
                                     Execute
       &                          Test Scripts
  Design Specs
                                 Test Expectation
                                        ≠
                            Executable Implementation




                         Develop Code,
                      Compile Executable
WTF
We’re supposed to be releasing
next week and you tell me this
isn’t working? Get that bug fixed!
The objective is

               to kill bugs quickly,
     but to
               AVOID
                    them altogether!
What if…
                 Requirements Specs = Test Specs = Acceptance Criteria
Greater Detail




                       We built the right thing.


                 Design Specs           = Test Specs = Quality Criteria
                       We built the thing right.
1968know our
How do we
programs are correct?



1) Construct a proof showing what the
   program should do




2) Develop code that
   meets the proof
REPEAT until done
     “A Constructive Approach
     To the Problem of Program Correctness”, 1968, Edsger Wybe Dijkstra
In 1968,
                       in fact not until the late 90s,


                           the tools
                   didn’t exist
               to implement Dr. Dijkstra’s vision.

      Today,
the Constructive   Approach    =     Test Driven Development (TDD)

             (Specs = Tests = Proofs)

Specs   Tests      Code          Test
                Development   Execution
Acceptance Tests  Stories/Functions
Greater Detail




                  Mark as ready for test when completed; based on Product Owner priority

                 xUnit Tests  Specific Detailed Methods/Functions
                  Test completed code
X Unit Tests



          Execute Test  Create Mock Data    Write Code
 Write
 Test(s)  to                 To           to
          Show Failure Show Passing Test(s) Pass Tests
           Why?                Why?                   Why?
            Know test will show Know test will show    Tests = Specs
            fail                pass (expected
                                results)




           Recurse over this pattern!
What does an xUnit
Test look like?

   Say you've got a method,

   getName(String path)

   that parses a file name from a file path.

   You can write a JUnit test class to feed it a path
   and ensure that the results are what you
   expected.
                                               Simple example from jGuru.com
import java.io.File;
import junit.framework.*;
import junit.extensions.*;

public class ThingTester extends TestCase
{
          public ThingTester (String name)
          {
                    super (name);
          }

         public static void main(String[] args)
         {
                    junit.textui.TestRunner.run(ThingTester.class);
         }

         public void testGetName() throws Exception
         {
                   File myFile = new File("c:xxxyyyzzz.txt");
                   assertEquals("zzz.txt", myFile.getName());
         }
}
To exercise the test:
Compile & run ThingTester.

• Little Dot = Passing Test;
• Assertion Failure & Stack Trace = Failure & location
• Write test code BEFORE program code used to
make it pass.

No problems? Add more test cases.
Examples: long paths, files with spaces in the
name, etc.
Stop when you feel you have enough edge cases
covered.
Understand Your Test Coverage

 Tests should cover all critical methods
 Tests should cover all critical edge cases
 Tests should cover all critical error detection

 Goal ≠ 100% coverage, but
 Goal = 100% passing for what is covered

-in your working code!
    (Including your tests!)
Acceptance Tests

        Write Test


   Describe     Describe  Execute Test Create Feature
   Desired     Feature  to                To
   Behavior    Test Steps Show Failure    Pass Test
                            Why?                   Why?
                             Know test will show     Tests = Specs
                             fail                  Underneath…
                                                     …are Unit Tests



              Recurse over this pattern!
What does an Acceptance Test1
look like?
   Say you've got a feature you want to implement
   to compute a factorial…

   You can write a feature that is the proof of this
   function or story (including edge cases)

   You also implement “steps” that poke at the
   implementation. As the implementation changes
   the steps change, but it is less common for the
   feature to change.
                                    1aka   Executable Specification
                                                    Example from tutorial at lettuce.it
computefactorial.feature

        Feature: Compute factorial
          In order to play with Lettuce
          As beginners
          We'll implement factorial

          Scenario: Factorial of 0
            Given I have the number 0
            When I compute its factorial
            Then I see the number 1




   Business Users can get this!
computefactorialsteps.py
        from lettuce import *

        @step('I have the number (d+)')
        def have_the_number(step, number):
                  world.number = int(number)

        @step('I compute its factorial')
        def compute_its_factorial(step):
                  world.number = factorial(world.number)

        @step('I see the number (d+)')
        def check_number(step, expected):
                  expected = int(expected)
                  assert world.number == expected, 
                           "Got %d" % world.number
To exercise the test:
Run Feature (duh!)




Add more code to fix problems and re-run….
computefactorial.py

         def factorial(number):
           return 1




        by definition, we know that the factorial of 0 is 1
        So as a mock, we created a function that just returned 1
To exercise the test:
Re-run Feature (duh!)




Need more than one case of course, so let’s add more
test cases; i.e. feature scenarios
Feature: Compute factorial
   In order to play with Lettuce
   As beginners
   We'll implement factorial

   Scenario: Factorial of 0
      Given I have the number 0
      When I compute its factorial
      Then I see the number 1




                                   }
   Scenario: Factorial of 1
      Given I have the number 1
      When I compute its factorial     In this case my steps
      Then I see the number 1          & asserts were
   Scenario: Factorial of 2            OK, sometimes you
      Given I have the number 2        have to create more
      When I compute its factorial
      Then I see the number 2
To exercise the test: Rerun Feature (duh!)




Change code to fix problems and re-run….
computefactorial.py

        def factorial(number):
          number = int(number)
          if (number == 0) or (number == 1):
                  return 1
          else:
                  return number
To exercise the test:
Rerun Feature (duh!)




Add a few more cases so we get realistic…
Feature: Compute factorial
   In order to play with Lettuce
   As beginners
   We'll implement factorial

   Scenario: Factorial of 0
      …

   Scenario: Factorial of 1
      …

   Scenario: Factorial of 2
      …




                                     }
   Scenario: Factorial of 3
      Given I have the number 3          Again my steps &
      When I compute its factorial
      Then I see the number 6            asserts were Ok this
                                         time,
Scenario: Factorial of 4                 sometimes you have
     Given I have the number 4
     When I compute its factorial        to create more
     Then I see the number 24
To exercise the test: Rerun Feature (duh!)
Change code to fix problems…

computefactorial.py

        def factorial(number):
          number = int(number)
          if (number == 0) or (number == 1):
              return 1
          else:
              return number*factorial(number-1)
To exercise the test: Rerun Feature (duh!)
Acceptance Tests work best when:
    • Driven off of methods (functions) or several functions
    • Perform below the UI level

If needed, Acceptance Tests can:
    • Be driven off of the UI (usually performs a little slower;
    must be done this way for something like PowerBuilder)
    • Can be done manually

The specification independent of the flow or implementation.
The steps that poke at underlying code may need modification
over time.

-in your working code!
    (Including your tests!)
How often?

 For unit tests…
 Every time code (which includes a test) is changed… This is probably
 multiple times a day and should be at a minimum daily.


 For acceptance tests…
 Whenever a test is completed and then the code is completed. The
 test may be completed on Tuesday, then code that pokes at the test
 will be completed as the skeletal object is completed say around
 Wednesday, and then perhaps Friday is when all the code for that
 poke is completed.
A Full Complement of Tests

                 Product       Technical   Interaction
                 Design         Design       Design


 Test to         Acceptance      xUnit         UI              Finite, Repeatable,
 Specification      Tests        Tests        Tests            Automated



 Test to         Exploratory      Stress     Usability         Environmental,
 Failure           Testing       Testing      Testing          Less Automated




                                               Diagram concept from p.76, Leading Lean
                                               Development, Mary & Tom Poppendieck, 2010
The Customer Satisfaction
Viewpoint…

Or why it matters…
For More Info…
References (Books)                    Unit Test Harnesses
• Specification by Example by         •   JUnit (java)
  Godjo Adzic                         •   Jasmine (JavaScript)
• Clean Code by Robert Martin         •   FlexUnit (Flex)
                                      •   pyUnit (Python)
• Ship It! By Jared Richardson
                                      •   utPLSQL (PL/SQL)
  and William Gwaltney
• JUnit in Action by Vincent          BDD (Acceptance Testing)
  Massol                              • JBehave (Java)
                                      • Cucumber (Ruby)
                                      • Lettuce (Python)
Google:                               UI Testing
Unit Testing <language of interest>   • Selenium

Mais conteúdo relacionado

Mais procurados

Testdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockTestdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockschlebu
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkArulalan T
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummiesHarry Potter
 
Programmer testing
Programmer testingProgrammer testing
Programmer testingJoao Pereira
 
Automated Testing in Django
Automated Testing in DjangoAutomated Testing in Django
Automated Testing in DjangoLoek van Gent
 
Easymock Tutorial
Easymock TutorialEasymock Tutorial
Easymock TutorialSbin m
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google MockICS
 
New Features Of Test Unit 2.x
New Features Of Test Unit 2.xNew Features Of Test Unit 2.x
New Features Of Test Unit 2.xdjberg96
 

Mais procurados (15)

Mockito
MockitoMockito
Mockito
 
Testdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockTestdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMock
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Unit testing, principles
Unit testing, principlesUnit testing, principles
Unit testing, principles
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Programmer testing
Programmer testingProgrammer testing
Programmer testing
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Automated Testing in Django
Automated Testing in DjangoAutomated Testing in Django
Automated Testing in Django
 
Easymock Tutorial
Easymock TutorialEasymock Tutorial
Easymock Tutorial
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
EasyMock for Java
EasyMock for JavaEasyMock for Java
EasyMock for Java
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
 
J Unit
J UnitJ Unit
J Unit
 
New Features Of Test Unit 2.x
New Features Of Test Unit 2.xNew Features Of Test Unit 2.x
New Features Of Test Unit 2.x
 

Destaque

Destaque (20)

Anixter Green Initiative
Anixter Green InitiativeAnixter Green Initiative
Anixter Green Initiative
 
男前豆腐店株式会社
男前豆腐店株式会社男前豆腐店株式会社
男前豆腐店株式会社
 
Aftershock
AftershockAftershock
Aftershock
 
Robot
RobotRobot
Robot
 
Chapter 4 colonial government
Chapter 4 colonial governmentChapter 4 colonial government
Chapter 4 colonial government
 
An operational perspective on the organisation of large scale field operation...
An operational perspective on the organisation of large scale field operation...An operational perspective on the organisation of large scale field operation...
An operational perspective on the organisation of large scale field operation...
 
Etxebizitzak Villabonan
Etxebizitzak VillabonanEtxebizitzak Villabonan
Etxebizitzak Villabonan
 
College Medema 2
College Medema 2College Medema 2
College Medema 2
 
Andalusia the landscape
Andalusia the landscapeAndalusia the landscape
Andalusia the landscape
 
Blowing in the_wind_vy
Blowing in the_wind_vyBlowing in the_wind_vy
Blowing in the_wind_vy
 
Inscape Corporate Brochure
Inscape Corporate BrochureInscape Corporate Brochure
Inscape Corporate Brochure
 
The Fallacy of Social Media Transparency
The Fallacy of Social Media TransparencyThe Fallacy of Social Media Transparency
The Fallacy of Social Media Transparency
 
Parallel Patterns Library (PPL) in Visual C++ 2010
Parallel Patterns Library (PPL) in Visual C++ 2010Parallel Patterns Library (PPL) in Visual C++ 2010
Parallel Patterns Library (PPL) in Visual C++ 2010
 
Pertussis en niños Lima
Pertussis en niños LimaPertussis en niños Lima
Pertussis en niños Lima
 
Informe Anual Mindshare - MetaMen
Informe Anual Mindshare -  MetaMenInforme Anual Mindshare -  MetaMen
Informe Anual Mindshare - MetaMen
 
Relative clauses
Relative clausesRelative clauses
Relative clauses
 
Treadmill Talk Show - Exercise Boosting Creativity
Treadmill Talk Show - Exercise Boosting CreativityTreadmill Talk Show - Exercise Boosting Creativity
Treadmill Talk Show - Exercise Boosting Creativity
 
NATURAKO ARRISKUAK - RG
NATURAKO ARRISKUAK - RGNATURAKO ARRISKUAK - RG
NATURAKO ARRISKUAK - RG
 
Moon
MoonMoon
Moon
 
School awards
School awardsSchool awards
School awards
 

Semelhante a Tdd pecha kucha_v2

Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testingdn
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test communityKerry Buckley
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)Steve Upton
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Describe's Full of It's
Describe's Full of It'sDescribe's Full of It's
Describe's Full of It'sJim Lynch
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionDionatan default
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)Amr E. Mohamed
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debuggingsvilen.ivanov
 
ABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development
ABAP Code Retreat Frankfurt 2016: TDD - Test Driven DevelopmentABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development
ABAP Code Retreat Frankfurt 2016: TDD - Test Driven DevelopmentHendrik Neumann
 
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAPABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAPABAPCodeRetreat
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 

Semelhante a Tdd pecha kucha_v2 (20)

Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testing
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test community
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Describe's Full of It's
Describe's Full of It'sDescribe's Full of It's
Describe's Full of It's
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Test Driven
Test DrivenTest Driven
Test Driven
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Rspec
RspecRspec
Rspec
 
The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debugging
 
ABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development
ABAP Code Retreat Frankfurt 2016: TDD - Test Driven DevelopmentABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development
ABAP Code Retreat Frankfurt 2016: TDD - Test Driven Development
 
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAPABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
ABAPCodeRetreat Frankfurt 2016 - TDD with ABAP
 
Unit test
Unit testUnit test
Unit test
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
Oxente BDD
Oxente BDDOxente BDD
Oxente BDD
 
Python unit testing
Python unit testingPython unit testing
Python unit testing
 

Mais de Paul Boos

User Story Splitting.pptx
User Story Splitting.pptxUser Story Splitting.pptx
User Story Splitting.pptxPaul Boos
 
Development Game with Purpose - AGS
Development Game with Purpose - AGSDevelopment Game with Purpose - AGS
Development Game with Purpose - AGSPaul Boos
 
Agile Dev - Game with Purpose - WIA&T
Agile Dev - Game with Purpose - WIA&TAgile Dev - Game with Purpose - WIA&T
Agile Dev - Game with Purpose - WIA&TPaul Boos
 
Agile Leadership 201: Enriching Management for AgileNoVA
Agile Leadership 201: Enriching Management for AgileNoVAAgile Leadership 201: Enriching Management for AgileNoVA
Agile Leadership 201: Enriching Management for AgileNoVAPaul Boos
 
Agile Leadership 201 for TriAgile
Agile Leadership 201 for TriAgileAgile Leadership 201 for TriAgile
Agile Leadership 201 for TriAgilePaul Boos
 
Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...
Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...
Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...Paul Boos
 
Agile Leadership 201: Enriching Management
Agile Leadership 201: Enriching ManagementAgile Leadership 201: Enriching Management
Agile Leadership 201: Enriching ManagementPaul Boos
 
Pass on Perfection
Pass on PerfectionPass on Perfection
Pass on PerfectionPaul Boos
 
Your Agile Leadership Journey: Leading People, Managing Paradoxes
Your Agile Leadership Journey: Leading People, Managing ParadoxesYour Agile Leadership Journey: Leading People, Managing Paradoxes
Your Agile Leadership Journey: Leading People, Managing ParadoxesPaul Boos
 
Business Models in the Non-Profit and Public Sectors
Business Models in the Non-Profit and Public SectorsBusiness Models in the Non-Profit and Public Sectors
Business Models in the Non-Profit and Public SectorsPaul Boos
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroPaul Boos
 
Trust Psychological Safety
Trust Psychological SafetyTrust Psychological Safety
Trust Psychological SafetyPaul Boos
 
Catalytic leadership no va agile webinar
Catalytic leadership   no va agile webinarCatalytic leadership   no va agile webinar
Catalytic leadership no va agile webinarPaul Boos
 
Understanding Lean & Agile Coaching Agile and Beyond 2018
Understanding Lean & Agile Coaching Agile and Beyond 2018Understanding Lean & Agile Coaching Agile and Beyond 2018
Understanding Lean & Agile Coaching Agile and Beyond 2018Paul Boos
 
Catalytic Leadership Agile Tour Montreal
Catalytic Leadership   Agile Tour MontrealCatalytic Leadership   Agile Tour Montreal
Catalytic Leadership Agile Tour MontrealPaul Boos
 
Understanding coaching presentation agile dc2017 v2
Understanding coaching presentation   agile dc2017 v2Understanding coaching presentation   agile dc2017 v2
Understanding coaching presentation agile dc2017 v2Paul Boos
 
Catalytic Leadership Agile2017
Catalytic Leadership   Agile2017Catalytic Leadership   Agile2017
Catalytic Leadership Agile2017Paul Boos
 
Understanding coaching presentation agile dc2017 - for publishing
Understanding coaching presentation   agile dc2017 - for publishingUnderstanding coaching presentation   agile dc2017 - for publishing
Understanding coaching presentation agile dc2017 - for publishingPaul Boos
 
Catalytic Leadership for AgileDC
Catalytic Leadership for AgileDCCatalytic Leadership for AgileDC
Catalytic Leadership for AgileDCPaul Boos
 

Mais de Paul Boos (20)

User Story Splitting.pptx
User Story Splitting.pptxUser Story Splitting.pptx
User Story Splitting.pptx
 
Development Game with Purpose - AGS
Development Game with Purpose - AGSDevelopment Game with Purpose - AGS
Development Game with Purpose - AGS
 
Agile Dev - Game with Purpose - WIA&T
Agile Dev - Game with Purpose - WIA&TAgile Dev - Game with Purpose - WIA&T
Agile Dev - Game with Purpose - WIA&T
 
Clue Retro
Clue RetroClue Retro
Clue Retro
 
Agile Leadership 201: Enriching Management for AgileNoVA
Agile Leadership 201: Enriching Management for AgileNoVAAgile Leadership 201: Enriching Management for AgileNoVA
Agile Leadership 201: Enriching Management for AgileNoVA
 
Agile Leadership 201 for TriAgile
Agile Leadership 201 for TriAgileAgile Leadership 201 for TriAgile
Agile Leadership 201 for TriAgile
 
Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...
Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...
Your Agile Leadership Journey: Leading People-Managing Paradoxes - Agile Char...
 
Agile Leadership 201: Enriching Management
Agile Leadership 201: Enriching ManagementAgile Leadership 201: Enriching Management
Agile Leadership 201: Enriching Management
 
Pass on Perfection
Pass on PerfectionPass on Perfection
Pass on Perfection
 
Your Agile Leadership Journey: Leading People, Managing Paradoxes
Your Agile Leadership Journey: Leading People, Managing ParadoxesYour Agile Leadership Journey: Leading People, Managing Paradoxes
Your Agile Leadership Journey: Leading People, Managing Paradoxes
 
Business Models in the Non-Profit and Public Sectors
Business Models in the Non-Profit and Public SectorsBusiness Models in the Non-Profit and Public Sectors
Business Models in the Non-Profit and Public Sectors
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for Distro
 
Trust Psychological Safety
Trust Psychological SafetyTrust Psychological Safety
Trust Psychological Safety
 
Catalytic leadership no va agile webinar
Catalytic leadership   no va agile webinarCatalytic leadership   no va agile webinar
Catalytic leadership no va agile webinar
 
Understanding Lean & Agile Coaching Agile and Beyond 2018
Understanding Lean & Agile Coaching Agile and Beyond 2018Understanding Lean & Agile Coaching Agile and Beyond 2018
Understanding Lean & Agile Coaching Agile and Beyond 2018
 
Catalytic Leadership Agile Tour Montreal
Catalytic Leadership   Agile Tour MontrealCatalytic Leadership   Agile Tour Montreal
Catalytic Leadership Agile Tour Montreal
 
Understanding coaching presentation agile dc2017 v2
Understanding coaching presentation   agile dc2017 v2Understanding coaching presentation   agile dc2017 v2
Understanding coaching presentation agile dc2017 v2
 
Catalytic Leadership Agile2017
Catalytic Leadership   Agile2017Catalytic Leadership   Agile2017
Catalytic Leadership Agile2017
 
Understanding coaching presentation agile dc2017 - for publishing
Understanding coaching presentation   agile dc2017 - for publishingUnderstanding coaching presentation   agile dc2017 - for publishing
Understanding coaching presentation agile dc2017 - for publishing
 
Catalytic Leadership for AgileDC
Catalytic Leadership for AgileDCCatalytic Leadership for AgileDC
Catalytic Leadership for AgileDC
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Tdd pecha kucha_v2

  • 1. What is Test-Driven Development? A Primer on Testable Specifications…
  • 2. Develop Traditional Testing Test Scripts Approach Error Found! Requirements Execute & Test Scripts Design Specs Test Expectation ≠ Executable Implementation Develop Code, Compile Executable
  • 3. WTF We’re supposed to be releasing next week and you tell me this isn’t working? Get that bug fixed!
  • 4. The objective is to kill bugs quickly, but to AVOID them altogether!
  • 5. What if… Requirements Specs = Test Specs = Acceptance Criteria Greater Detail We built the right thing. Design Specs = Test Specs = Quality Criteria We built the thing right.
  • 6. 1968know our How do we programs are correct? 1) Construct a proof showing what the program should do 2) Develop code that meets the proof REPEAT until done “A Constructive Approach To the Problem of Program Correctness”, 1968, Edsger Wybe Dijkstra
  • 7. In 1968, in fact not until the late 90s, the tools didn’t exist to implement Dr. Dijkstra’s vision. Today, the Constructive Approach = Test Driven Development (TDD) (Specs = Tests = Proofs)
  • 8.  Specs Tests Code Test Development Execution
  • 9. Acceptance Tests  Stories/Functions Greater Detail Mark as ready for test when completed; based on Product Owner priority xUnit Tests  Specific Detailed Methods/Functions Test completed code
  • 10. X Unit Tests Execute Test Create Mock Data Write Code Write Test(s)  to  To  to Show Failure Show Passing Test(s) Pass Tests Why? Why? Why? Know test will show Know test will show Tests = Specs fail pass (expected results) Recurse over this pattern!
  • 11. What does an xUnit Test look like? Say you've got a method, getName(String path) that parses a file name from a file path. You can write a JUnit test class to feed it a path and ensure that the results are what you expected. Simple example from jGuru.com
  • 12. import java.io.File; import junit.framework.*; import junit.extensions.*; public class ThingTester extends TestCase { public ThingTester (String name) { super (name); } public static void main(String[] args) { junit.textui.TestRunner.run(ThingTester.class); } public void testGetName() throws Exception { File myFile = new File("c:xxxyyyzzz.txt"); assertEquals("zzz.txt", myFile.getName()); } }
  • 13. To exercise the test: Compile & run ThingTester. • Little Dot = Passing Test; • Assertion Failure & Stack Trace = Failure & location • Write test code BEFORE program code used to make it pass. No problems? Add more test cases. Examples: long paths, files with spaces in the name, etc. Stop when you feel you have enough edge cases covered.
  • 14. Understand Your Test Coverage Tests should cover all critical methods Tests should cover all critical edge cases Tests should cover all critical error detection Goal ≠ 100% coverage, but Goal = 100% passing for what is covered
  • 15.  -in your working code! (Including your tests!)
  • 16. Acceptance Tests Write Test Describe Describe Execute Test Create Feature Desired  Feature  to  To Behavior Test Steps Show Failure Pass Test Why? Why? Know test will show Tests = Specs fail Underneath… …are Unit Tests Recurse over this pattern!
  • 17. What does an Acceptance Test1 look like? Say you've got a feature you want to implement to compute a factorial… You can write a feature that is the proof of this function or story (including edge cases) You also implement “steps” that poke at the implementation. As the implementation changes the steps change, but it is less common for the feature to change. 1aka Executable Specification Example from tutorial at lettuce.it
  • 18. computefactorial.feature Feature: Compute factorial In order to play with Lettuce As beginners We'll implement factorial Scenario: Factorial of 0 Given I have the number 0 When I compute its factorial Then I see the number 1 Business Users can get this!
  • 19. computefactorialsteps.py from lettuce import * @step('I have the number (d+)') def have_the_number(step, number): world.number = int(number) @step('I compute its factorial') def compute_its_factorial(step): world.number = factorial(world.number) @step('I see the number (d+)') def check_number(step, expected): expected = int(expected) assert world.number == expected, "Got %d" % world.number
  • 20. To exercise the test: Run Feature (duh!) Add more code to fix problems and re-run….
  • 21. computefactorial.py def factorial(number): return 1 by definition, we know that the factorial of 0 is 1 So as a mock, we created a function that just returned 1
  • 22. To exercise the test: Re-run Feature (duh!) Need more than one case of course, so let’s add more test cases; i.e. feature scenarios
  • 23. Feature: Compute factorial In order to play with Lettuce As beginners We'll implement factorial Scenario: Factorial of 0 Given I have the number 0 When I compute its factorial Then I see the number 1 } Scenario: Factorial of 1 Given I have the number 1 When I compute its factorial In this case my steps Then I see the number 1 & asserts were Scenario: Factorial of 2 OK, sometimes you Given I have the number 2 have to create more When I compute its factorial Then I see the number 2
  • 24. To exercise the test: Rerun Feature (duh!) Change code to fix problems and re-run….
  • 25. computefactorial.py def factorial(number): number = int(number) if (number == 0) or (number == 1): return 1 else: return number
  • 26. To exercise the test: Rerun Feature (duh!) Add a few more cases so we get realistic…
  • 27. Feature: Compute factorial In order to play with Lettuce As beginners We'll implement factorial Scenario: Factorial of 0 … Scenario: Factorial of 1 … Scenario: Factorial of 2 … } Scenario: Factorial of 3 Given I have the number 3 Again my steps & When I compute its factorial Then I see the number 6 asserts were Ok this time, Scenario: Factorial of 4 sometimes you have Given I have the number 4 When I compute its factorial to create more Then I see the number 24
  • 28. To exercise the test: Rerun Feature (duh!)
  • 29. Change code to fix problems… computefactorial.py def factorial(number): number = int(number) if (number == 0) or (number == 1): return 1 else: return number*factorial(number-1)
  • 30. To exercise the test: Rerun Feature (duh!)
  • 31. Acceptance Tests work best when: • Driven off of methods (functions) or several functions • Perform below the UI level If needed, Acceptance Tests can: • Be driven off of the UI (usually performs a little slower; must be done this way for something like PowerBuilder) • Can be done manually The specification independent of the flow or implementation. The steps that poke at underlying code may need modification over time.
  • 32.  -in your working code! (Including your tests!)
  • 33. How often? For unit tests… Every time code (which includes a test) is changed… This is probably multiple times a day and should be at a minimum daily. For acceptance tests… Whenever a test is completed and then the code is completed. The test may be completed on Tuesday, then code that pokes at the test will be completed as the skeletal object is completed say around Wednesday, and then perhaps Friday is when all the code for that poke is completed.
  • 34. A Full Complement of Tests Product Technical Interaction Design Design Design Test to Acceptance xUnit UI Finite, Repeatable, Specification Tests Tests Tests Automated Test to Exploratory Stress Usability Environmental, Failure Testing Testing Testing Less Automated Diagram concept from p.76, Leading Lean Development, Mary & Tom Poppendieck, 2010
  • 36. For More Info… References (Books) Unit Test Harnesses • Specification by Example by • JUnit (java) Godjo Adzic • Jasmine (JavaScript) • Clean Code by Robert Martin • FlexUnit (Flex) • pyUnit (Python) • Ship It! By Jared Richardson • utPLSQL (PL/SQL) and William Gwaltney • JUnit in Action by Vincent BDD (Acceptance Testing) Massol • JBehave (Java) • Cucumber (Ruby) • Lettuce (Python) Google: UI Testing Unit Testing <language of interest> • Selenium