SlideShare a Scribd company logo
1 of 24
Introduction to
Test Driven Development
           And
         Mocking
        @saeed_shargi
The Problem
Time taken to fix bugs
1000



750



500



250



  0
        Design   Implementation   QA   Post-Release
Solution


   Testing

   Test Driven Development
Testing



Design   Implementation   Test
TDD



Design   Test   Implementation
TDD



Design   Test     Implementation   Test
TDD
          Design




Test                    Test




       Implementation
TDD
          Design




Test                    Test




       Implementation
What is TDD?
 Write a test before writing a code.
 Specification not validation
 Think through requirements or design
  before write code.
 Programming technique
 Ron Jefferies -> write clean code
What is TDD?
What is TDD?
What is TDD?



TDD = Refactoring + TFD
Two Level of TDD

1)   Acceptance TDD (ATDD)



2)   Developer TDD
ATDD and TDD Together
Development Style


1)   KISS
               Writing only the code
               necessary to pass test
2)   YAGNI
Benefits
1)   Suit unit test provides that components
     working.
2)   Clear code
3)   Forces critical analysis and design
4)   Better design , loosely coupled , easily
     maintainable
5)   Reduced debugging time
Tools
   Cpputest
   csUnit (.Net)
   Cunit
   Dunit (Delphi)
   DBUnit
   JUnit
   NUnit
   PHPUnit
   xUnit.net
Mocking
 Simple classes dose not have
  dependencies.
 In Action classes maybe have external
  dependencies like connect to database
  , connect to web services.
 Good Test should be isolated.
 Integration test.
 Test should be fast.
Mocking

   Two way to isolated :

    1) Use Interface
    2) Mocking framework
Example of using Interface
   Interfaces to isolated database and
    web services :

public interface IEmailSource
{
  IEnumerable<string> GetEmailAddresses();
}

public interface IEmailDataStore
{
  void SaveEmailAddresses(IEnumerable<string> emailAddresses);

}
Example of using Interface
      Mock classes :
    public class MockEmailSource : IEmailSource
    {
      public IEnumerable<string> EmailAddressesToReturn { get; set; }
      public IEnumerable<string> GetEmailAddresses()
      {
        return EmailAddressesToReturn;
      }
    }

    public class MockEmailDataStore : IEmailDataStore
    {
      public IEnumerable<string> SavedEmailAddresses { get; set; }
      public void SaveEmailAddresses(IEnumerable<string> emailAddresses)
      {
        SavedEmailAddresses = emailAddresses;
      }
    }
Mocking Frameworks
 Nmock
 Moq
 Rhino Mocks
 TypeMock
 EasyMock.Net
Introduction to TDD and Mocking

More Related Content

What's hot

TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010Stefano Paluello
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy CodeAndrea Polci
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010guest5639fa9
 
Unit testing legacy code
Unit testing legacy codeUnit testing legacy code
Unit testing legacy codeLars Thorup
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy CodeExcella
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy CodeAdam Culp
 
Clean code - Getting your R&D on board
Clean code - Getting your R&D on boardClean code - Getting your R&D on board
Clean code - Getting your R&D on boardRuth Sperer
 
How we tested our code "Google way"
How we tested our code "Google way"How we tested our code "Google way"
How we tested our code "Google way"Oleksiy Rezchykov
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestableRoyKlein
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionDionatan default
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: LegacyVictor_Cr
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)nedirtv
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Zohirul Alam Tiemoon
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief exampleJeremy Kendall
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) CodeOps Technologies LLP
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development CodeOps Technologies LLP
 
Quickly and Effectively Testing Legacy c++ Code with Approval Tests mu cpp
Quickly and Effectively Testing Legacy c++ Code with Approval Tests   mu cppQuickly and Effectively Testing Legacy c++ Code with Approval Tests   mu cpp
Quickly and Effectively Testing Legacy c++ Code with Approval Tests mu cppClare Macrae
 
Top 20 cucumber interview questions for sdet
Top 20 cucumber interview questions for sdetTop 20 cucumber interview questions for sdet
Top 20 cucumber interview questions for sdetDevLabs Alliance
 

What's hot (20)

TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
 
Unit testing legacy code
Unit testing legacy codeUnit testing legacy code
Unit testing legacy code
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Clean code - Getting your R&D on board
Clean code - Getting your R&D on boardClean code - Getting your R&D on board
Clean code - Getting your R&D on board
 
How we tested our code "Google way"
How we tested our code "Google way"How we tested our code "Google way"
How we tested our code "Google way"
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: Legacy
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief example
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD)
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Quickly and Effectively Testing Legacy c++ Code with Approval Tests mu cpp
Quickly and Effectively Testing Legacy c++ Code with Approval Tests   mu cppQuickly and Effectively Testing Legacy c++ Code with Approval Tests   mu cpp
Quickly and Effectively Testing Legacy c++ Code with Approval Tests mu cpp
 
Top 20 cucumber interview questions for sdet
Top 20 cucumber interview questions for sdetTop 20 cucumber interview questions for sdet
Top 20 cucumber interview questions for sdet
 

Viewers also liked

Service Virtualization - Next Gen Testing Conference Singapore 2013
Service Virtualization - Next Gen Testing Conference Singapore 2013Service Virtualization - Next Gen Testing Conference Singapore 2013
Service Virtualization - Next Gen Testing Conference Singapore 2013Min Fang
 
Is Groovy better for testing than Java?
Is Groovy better for testing than Java?Is Groovy better for testing than Java?
Is Groovy better for testing than Java?Trisha Gee
 
Noble Purpose: How to Win the Hearts and Minds of Your Employees
Noble Purpose: How to Win the Hearts and Minds of Your EmployeesNoble Purpose: How to Win the Hearts and Minds of Your Employees
Noble Purpose: How to Win the Hearts and Minds of Your EmployeesLisa Earle McLeod
 
TDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzzTDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzzRick Liu
 
Stub Testing and Driver Testing
Stub Testing and Driver TestingStub Testing and Driver Testing
Stub Testing and Driver TestingPopescu Petre
 
Test Driven Development (C#)
Test Driven Development (C#)Test Driven Development (C#)
Test Driven Development (C#)Alan Dean
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoElad Elrom
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 
The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecBen Mabey
 
Unit 18 compare and contrast presentation
Unit 18 compare and contrast presentationUnit 18 compare and contrast presentation
Unit 18 compare and contrast presentationLisa
 

Viewers also liked (20)

Tdd - introduction
Tdd - introductionTdd - introduction
Tdd - introduction
 
Service Virtualization - Next Gen Testing Conference Singapore 2013
Service Virtualization - Next Gen Testing Conference Singapore 2013Service Virtualization - Next Gen Testing Conference Singapore 2013
Service Virtualization - Next Gen Testing Conference Singapore 2013
 
TDD and BDD in Java 8 - what's in it for me?
TDD and BDD in Java 8 - what's in it for me?TDD and BDD in Java 8 - what's in it for me?
TDD and BDD in Java 8 - what's in it for me?
 
Is Groovy better for testing than Java?
Is Groovy better for testing than Java?Is Groovy better for testing than Java?
Is Groovy better for testing than Java?
 
Rapport diagnostic numérique 2012
Rapport diagnostic numérique 2012Rapport diagnostic numérique 2012
Rapport diagnostic numérique 2012
 
Noble Purpose: How to Win the Hearts and Minds of Your Employees
Noble Purpose: How to Win the Hearts and Minds of Your EmployeesNoble Purpose: How to Win the Hearts and Minds of Your Employees
Noble Purpose: How to Win the Hearts and Minds of Your Employees
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
TDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzzTDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzz
 
Lisa
LisaLisa
Lisa
 
Stub Testing and Driver Testing
Stub Testing and Driver TestingStub Testing and Driver Testing
Stub Testing and Driver Testing
 
Test Driven Development (C#)
Test Driven Development (C#)Test Driven Development (C#)
Test Driven Development (C#)
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
 
La virtualisation
La virtualisationLa virtualisation
La virtualisation
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
TDD Overview
TDD OverviewTDD Overview
TDD Overview
 
La virtualisation
La virtualisationLa virtualisation
La virtualisation
 
The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpec
 
Unit 18 compare and contrast presentation
Unit 18 compare and contrast presentationUnit 18 compare and contrast presentation
Unit 18 compare and contrast presentation
 

Similar to Introduction to TDD and Mocking

Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tddeduardomg23
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
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
 
Mercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin SlidesMercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin Slidestelab
 
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014eduardomg23
 
Tdd on play framework
Tdd on play frameworkTdd on play framework
Tdd on play frameworkvuhaininh88
 
TDD- Test Driven Development
TDD- Test Driven DevelopmentTDD- Test Driven Development
TDD- Test Driven DevelopmentLiza Antoun
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Gianluca Padovani
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicDavid Solivan
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionPyxis Technologies
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentMichael Denomy
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio
 
TDD in functional testing with WebDriver
TDD in functional testing with WebDriverTDD in functional testing with WebDriver
TDD in functional testing with WebDriverMikalai Alimenkou
 
BDD and Test Automation in Evalutionary Product Suite
BDD and Test Automation in Evalutionary Product SuiteBDD and Test Automation in Evalutionary Product Suite
BDD and Test Automation in Evalutionary Product SuiteLasantha Ranaweera
 

Similar to Introduction to TDD and Mocking (20)

Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tdd
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Mercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin SlidesMercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin Slides
 
TDD refresher
TDD refresherTDD refresher
TDD refresher
 
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
 
Tdd on play framework
Tdd on play frameworkTdd on play framework
Tdd on play framework
 
Coding Naked
Coding NakedCoding Naked
Coding Naked
 
TDD- Test Driven Development
TDD- Test Driven DevelopmentTDD- Test Driven Development
TDD- Test Driven Development
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs Public
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
Tdd blog
Tdd blogTdd blog
Tdd blog
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code Testing
 
NET Code Testing
NET Code TestingNET Code Testing
NET Code Testing
 
TDD in functional testing with WebDriver
TDD in functional testing with WebDriverTDD in functional testing with WebDriver
TDD in functional testing with WebDriver
 
BDD and Test Automation in Evalutionary Product Suite
BDD and Test Automation in Evalutionary Product SuiteBDD and Test Automation in Evalutionary Product Suite
BDD and Test Automation in Evalutionary Product Suite
 

Recently uploaded

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Introduction to TDD and Mocking

  • 1. Introduction to Test Driven Development And Mocking @saeed_shargi
  • 3. Time taken to fix bugs 1000 750 500 250 0 Design Implementation QA Post-Release
  • 4. Solution  Testing  Test Driven Development
  • 5. Testing Design Implementation Test
  • 6. TDD Design Test Implementation
  • 7. TDD Design Test Implementation Test
  • 8. TDD Design Test Test Implementation
  • 9. TDD Design Test Test Implementation
  • 10. What is TDD?  Write a test before writing a code.  Specification not validation  Think through requirements or design before write code.  Programming technique  Ron Jefferies -> write clean code
  • 13. What is TDD? TDD = Refactoring + TFD
  • 14. Two Level of TDD 1) Acceptance TDD (ATDD) 2) Developer TDD
  • 15. ATDD and TDD Together
  • 16. Development Style 1) KISS Writing only the code necessary to pass test 2) YAGNI
  • 17. Benefits 1) Suit unit test provides that components working. 2) Clear code 3) Forces critical analysis and design 4) Better design , loosely coupled , easily maintainable 5) Reduced debugging time
  • 18. Tools  Cpputest  csUnit (.Net)  Cunit  Dunit (Delphi)  DBUnit  JUnit  NUnit  PHPUnit  xUnit.net
  • 19. Mocking  Simple classes dose not have dependencies.  In Action classes maybe have external dependencies like connect to database , connect to web services.  Good Test should be isolated.  Integration test.  Test should be fast.
  • 20. Mocking  Two way to isolated : 1) Use Interface 2) Mocking framework
  • 21. Example of using Interface  Interfaces to isolated database and web services : public interface IEmailSource { IEnumerable<string> GetEmailAddresses(); } public interface IEmailDataStore { void SaveEmailAddresses(IEnumerable<string> emailAddresses); }
  • 22. Example of using Interface  Mock classes : public class MockEmailSource : IEmailSource { public IEnumerable<string> EmailAddressesToReturn { get; set; } public IEnumerable<string> GetEmailAddresses() { return EmailAddressesToReturn; } } public class MockEmailDataStore : IEmailDataStore { public IEnumerable<string> SavedEmailAddresses { get; set; } public void SaveEmailAddresses(IEnumerable<string> emailAddresses) { SavedEmailAddresses = emailAddresses; } }
  • 23. Mocking Frameworks  Nmock  Moq  Rhino Mocks  TypeMock  EasyMock.Net