Your SlideShare is downloading. ×
0
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Introduction to TDD and Mocking
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction to TDD and Mocking

3,602

Published on

introduction to test driven development and mocking

introduction to test driven development and mocking

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,602
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
62
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction toTest Driven Development And Mocking @saeed_shargi
  • 2. The Problem
  • 3. Time taken to fix bugs1000750500250 0 Design Implementation QA Post-Release
  • 4. Solution Testing Test Driven Development
  • 5. TestingDesign Implementation Test
  • 6. TDDDesign Test Implementation
  • 7. TDDDesign Test Implementation Test
  • 8. TDD DesignTest Test Implementation
  • 9. TDD DesignTest 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
  • 11. What is TDD?
  • 12. What is TDD?
  • 13. What is TDD?TDD = Refactoring + TFD
  • 14. Two Level of TDD1) Acceptance TDD (ATDD)2) Developer TDD
  • 15. ATDD and TDD Together
  • 16. Development Style1) KISS Writing only the code necessary to pass test2) YAGNI
  • 17. Benefits1) Suit unit test provides that components working.2) Clear code3) Forces critical analysis and design4) Better design , loosely coupled , easily maintainable5) 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

×