Your SlideShare is downloading. ×
0
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
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

Benefit From Unit Testing In The Real World

4,425

Published on

Published in: Technology
2 Comments
7 Likes
Statistics
Notes
  • Why not share a link instead
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • It was a nice presentation!

    Wanted to download this and share with a fellow-developers (around 20 in headcount), who live with typemock and tdd. Also, found that the link you gave in drorhelper.com is also broken. :(
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
4,425
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
2
Likes
7
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
  • The lecture today will be divided into four parts:1 Overview of Unit tests and TDD and how it could save money for companies and improve software development process2 Typical day (but nor all day) of a software developer that uses TDD3 Real examples of Unit testing in non trivial cases4 Answer questions from the audience about the lecture, TDD & Unit testing in their companies
  • How a software company can benefit from unit testing Question to audience:Who knows what are unit tests?Who uses unit tests?Who practices TDD?
  • Why unit test:Define unit testing, define isolationMotivationWhy not do unit testing?Benefits: regression, confidence in changeStatistics Examples of companies that unit testCommon misconceptions:Not all tests are unit tests (integration vs. unit testing)Unit tests are for developers, not QAIntroducing TDDTools:Unit testing frameworksR#Mocking frameworksTeamCity/Team SystemFinalBuilder/msbuild/ccnet
  • Show unit test parts:Declaration (attribute)Run code under testAssertion – did satisfy condition Usually we have an additional part that arrange the needed componentsShould this be a new slide? What does unit test test?Functional requirememts
  • First explain - Difference between unit testing – how and tdd - methodologyTest Driven Development (or test driven design) is a methodology.Write a test that failsRun tests – why should we – to make sure the test actually checks the right thingWrite codeRefactorRepeat if nessesary
  • No that we understand what is unit testing and TDD I’d like
  • Taken from http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdfRealizing quality improvement through test driven development: results and experiences of four industrial teamsPublished online: 27 February 2008
  • - One known fact is that most of the bugs are introduced during the development stage.Another known fact is that the cost to fix a defect increases exponentially over stages.When bug is found at Testing phase the application needs to go back to development and it actually takes more time!It would be better to find/fix/not create bugs during development afterward it’s too late.We get a costly fix and frustrated clients.Show bugs in testing/supprt – where did they come from? Every few defects fixed a new defect is introducedOur pain in at the dev stage however many companies invest most of their money on QA & support
  • Give example about massive refactoring of new code.Function/code afraid to touch…
  • Examples DB, WCF
  • Has Teardown/Setup functionalityRun Unit tests
  • How to test part of a whole system
  • The backbone of TDD (and development)Show how CI & script runner run the test suite – perhaps publish results to web
  • Continuous integration is the backbone of TDD. Without test runner that runs each time code changes it is impossible to make sure that nothing was broken.
  • Should show:? Get code from server ?MSTest/NUnit
  • Should show:NUnit
  • Resharper
  • Transcript

    • 1. Dror Helper - http://blogs.microsoft.co.il/blogs/dhelper Doron Peretz – http://twitter.com/doronp Typemock Ltd. Typemock™
    • 2. Typemock™  Typemock Isolator  Established 2005, privately owned  Thousands of customers (Fortune 500)  Tens of thousands licenses sold Typemock™
    • 3. Agenda  Using TDD for Fun & Profit  A day in the life of TDD developer  Testing difficult scenarios  Share the Pain! Typemock™
    • 4. ` How to implement unit testing in your development team Typemock™
    • 5. Sounds Familiar? 20:00 – One bug left before release 20:01 - Done! 20:02 - Send version to QA, call wife 20:05 - On the way to the elevator. QA: It doesn’t work! 22:50 - What have I done?! Typemock™
    • 6. Unit testing for Fun & Profit  Short Overview: Unit Test, TDD  Why unit test?  Things you thought you knew  Tools you need to know about Typemock™
    • 7. Overview What is Unit Test?  Verifies an atomic piece of code  Tests one specific behavior  Each Test is autonomous [TestMethod] public void CheckPassword_ValidUser_ReturnTrue() { bool result = CheckPassword(“user”, “pass”); Assert.IsTrue(result); } Typemock™
    • 8. Overview Test Driven Development Write new Test Run Refactor Tests Run Write Tests code Typemock™
    • 9. Why Unit Test? Why not use Unit Test Testing is for QA Time = Cost Integration Testing find more bugs Manual Testing find more bugs It’s like writing the code twice Typemock™
    • 10. Why Unit Test? Is TDD a Waste of Time? Time taken to code a feature 140% 135% 120% 125% 120% 115% 100% 80% 60% 40% 20% 0% IBM: Drivers MS: Windows MS: MSN MS: VS WithoutTDD Using TDD Typemock™
    • 11. Why Unit Test? Is TDD a Waste of Time? Using Test Driven Design 140% 120% 100% 80% 61% 60% 38% 40% 24% 20% 9% 0% IBM: Drivers MS: Windows MS: MSN MS: VS Major quality improvement for minor time investment Time To Code Feature Defect density of team Typemock™
    • 12. Why Unit Test? So Why Unit Test? Where does it hurt? 100% 10 The pain is here! This is too late… 9 80% 8 % defects created 7 Thousand $s 60% 6 5 40% 4 3 20% 2 1 0% 0 Requirements Coding Integration Testing Typemock™ Support % of Defects Introduced Cost to Fix a Defect
    • 13. Misconceptions TDD is not about testing  TDD is about design and development  By testing first you design your code Typemock™
    • 14. Misconceptions Unit Tests are written by developers!  Increase confidence in code  Fearlessly change your code  Document requirements  Discover usability issues early Typemock™
    • 15. Misconceptions Unit Tests are Not Integration  Unit tests should be:  Small  Atomic  Test a single functional unit  Isolated!  Integration tests are used to test system wide functionality Typemock™
    • 16. Tools Unit Testing Frameworks  Consensus – NUnit  Integrated – MSTest  New kid on the block – XUnit  Performance oriented – Zenebug  Meta framework- Gallio (MBUnit) Typemock™
    • 17. Tools Mocking / Isolation  Each unit test MUST be isolated  How do we test business logic without Database calls? Typemock™
    • 18. Tools Isolation – Mocking frameowrks Open Source:  NMock2  Moq  Rhino Mocks Commercial (costs money but worth it)  Typemock Isolator Typemock™
    • 19. Tools Visual Studio Integration Refactoring  Code Rush  R# Unit test runners  TestDriven.NET  R# Test Runner Typemock™
    • 20. Tools Continuous Integration Build Server (TeamCity) What’s new? Commit There you go Source Control (SVN) We automatically got •Error reports & logs •New version installer •Help files •More… Build Agents Typemock™ (FinalBuilder)
    • 21. Tools Continuous Integration Computer Says NO! Build Automation Tools  NAnt  MSBuild  FinalBuilder CI Servers  CCnet  TeamCity  Team System / Team Foundation Server  FinalBuilder Server Typemock™
    • 22. ` Examples, demonstrations & fun Typemock™
    • 23. A Day in the Life of a TDD'er  The tools we use at Typemock  Writing some code  OK, who broke the Build?!  Too much spare time… Typemock™
    • 24. Our Tools The Tools We Use  Unit testing – MSTest/NUnit  Build automation – FinalBuilder Typemock™
    • 25. Our Tools Build Script at a Glance Typemock™
    • 26. Our Tools The Tools We Use  Unit testing – MSTest/NUnit  Build automation – FinalBuilder  Continuous Integration – TeamCity Typemock™
    • 27. Our Tools TeamCity at a Glance Typemock™
    • 28. Our Tools The Tools We Use  Unit testing – MSTest/NUnit  Build automation – FinalBuilder  Continuous Integration – TeamCity  Integrated tools – R#, TestDriven.NET  Isolation Framework – Isolator (surprise!)  Build Bunny! Typemock™
    • 29. Write Code Writing Some Code  We begin with a clean slate Write new test Run Refactor tests Run All Write tests code Typemock™
    • 30. Write Code Writing Some Code  An exercise in futility… Write new test Run Refactor tests Run all Write tests code Typemock™
    • 31. Write Code Writing Some Code  Now we get our hands dirty Write new Test Run Refactor tests Run all Write tests code Typemock™
    • 32. Write Code Writing Some Code  Make sure everything’s fine… Write new Test Run Refactor tests Run all Write tests code Typemock™
    • 33. Write Code Writing Some Code  … and make it perform/look better Write new test Run Refactor tests Run all Write tests code Typemock™
    • 34. Write Code Writing Some Code  Lets take her out for another spin… Write new Test Run Refactor tests Run all Write tests code Typemock™
    • 35. Broken Build OK, Who Broke the Build?  Something went horribly wrong!  And it’s easy to find who to blame   But it’s easy to find out what happened  Why is this important?  The project heartbeat  Healthy build == easy to release Typemock™
    • 36. Spare Time Too Much Spare Time  The foosball table  The build bunny  The Shooting of The Zombies  Helping children with computer skills Typemock™
    • 37. Not everything in life is easy… Typemock™
    • 38. Examples from the real world  Hard to unit test scenarios  How to solve this problem  Examples Typemock™
    • 39. Difficult scenarios to Unit Test  Client – server architecture  Databases  Legacy Code  Closed Object Models (Sharepoint, Silverlight)  GUI interaction Typemock™
    • 40. Possible solutions  First - better understand the problem  Design for Testability  Refactoring for Testability  Reflection  Mocks / Isolation  Last resort - Integration tests instead Typemock™
    • 41. Example Unit Testing WCF Client Class: WCF Client Method: string GetSourceList(string source); Problem: Server connection is not possible Typemock™
    • 42. Unit Testing WCF Client Overview: DataProviderClient DataProviderServer ISourceListProvider GetSourceList Typemock™
    • 43. Unit Testing Windows Forms Database Registration Form Business Logic Registration Controller Typemock™
    • 44. Share The Pain  Your unit testing stories  Q&A Typemock™
    • 45. Thank you Want to learn more? Read about Test Driven Development & Isolation at the Typemock Insiders blog Follow up on twitter.com/Typemock Take a card and drop us an email! Typemock™

    ×