Successfully reported this slideshow.
Upcoming SlideShare
×

# Introduction to TDD and Mocking

4,871 views

Published on

introduction to test driven development and mocking

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
• I didn't think failing my maths back in high school would come back to haunt me but it did! After graduating from Edge Hill University, I was looking to undertake a PGCE in primary teaching. However, one of the requirements was a pass in GCSE maths so I had no choice but to re-take it. After failing it twice, my confidence was very low and I didn't think I could qualify for the PGCE. After running a Google search on passing GCSE maths, I came across Jeevan's revision system. The feedback it received looked very good so I decided to give it a try... And it was one of the best decisions I've ever made. After going through Jeevan's guide, I managed to grasp the entire subject and I passed my next GCSE maths exam, with ease. He (Jeevan) provided me with all the tools I needed to prepare for the exam. Together with his guidance, my pass was a foregone conclusion. Thank you so much Jeevan! You have potentially changed my life. I recommend anyone seeking a pass grade in GCSE maths to purchase this fantastic package!★★★ http://t.cn/AirraVnG

Are you sure you want to  Yes  No

### Introduction to TDD and Mocking

1. 1. Introduction toTest Driven Development And Mocking @saeed_shargi
2. 2. The Problem
3. 3. Time taken to fix bugs1000750500250 0 Design Implementation QA Post-Release
4. 4. Solution Testing Test Driven Development
5. 5. TestingDesign Implementation Test
6. 6. TDDDesign Test Implementation
7. 7. TDDDesign Test Implementation Test
8. 8. TDD DesignTest Test Implementation
9. 9. TDD DesignTest Test Implementation
10. 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. 11. What is TDD?
12. 12. What is TDD?
13. 13. What is TDD?TDD = Refactoring + TFD
14. 14. Two Level of TDD1) Acceptance TDD (ATDD)2) Developer TDD
15. 15. ATDD and TDD Together
16. 16. Development Style1) KISS Writing only the code necessary to pass test2) YAGNI
17. 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. 18. Tools Cpputest csUnit (.Net) Cunit Dunit (Delphi) DBUnit JUnit NUnit PHPUnit xUnit.net
19. 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. 20. Mocking Two way to isolated : 1) Use Interface 2) Mocking framework
21. 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. 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. 23. Mocking Frameworks Nmock Moq Rhino Mocks TypeMock EasyMock.Net