SlideShare a Scribd company logo
1 of 12
Macedonian Visual C# user group
           https://www.facebook.com/mkvcsug
http://mkdot.net/community/mknetug/mk_vcs/default.aspx




               Fake
              Mocking
              Dummy
                Wekoslav Stefanovski
                 swekster@gmail.com
                  sweko@mtdot.net
Why test software
• Bugs are bad, m’kay?
• Provides demonstrative proof that business
  requirements have been met
• Reduces risk of failures (or incidents) once systems are
  transferred to live operation
• Assures that the users for which the solution was
  designed are able to operate productively.
   – Performant
   – Reliable
   – Secure (and safe)
• When to stop testing?
Why unit test software
• White – box testing
• Created by people with best knowledge of the
  system
• Unit testing promotes flexible design
• Better complexity management
• Automating tests lead to fearless coding
• Free regression coverage
Unit testing myths
• “Testers test, developers develop”
• “Its dull to write tests.”
• “There’s no time to write tests.”
• “We’ll write the unit tests later.”
• “The code will change, so the tests will fail in
  the (near) future.”
• “The test we wrote some time ago (probably)
  don’t work anymore.”
Unit testing myths
• “Unit testing is weak at finding problems
  that haven’t been considered.”
• “It takes too much time and effort to think of
  all possible cases and write all those tests.”
• “Methods not being easily testable”
• “Not feasible for big projects”
• “Not feasible for existing projects”
Unit testing myths
•   “It saves money”
•   “It reduces the number of bugs”
•   “It brings a higher code quality”
•   “It improves performance”
•   “It’s easy to unit-test concurrency”
Fakes and Stubs and Mocks, oh my
• Dummy
  Just a placeholder object, unused and unusable
• Stub
  A placeholder implementation, returning defaults
• Fake
  A working, albeit trivial implementation
• Mock
  A simulated object that mimics behavior
How to unit test in .net
•   NUnit
•   MSTest
•   TestDriven
•   Moq
•   RhinoMocks
•   Typemock
•   Microsoft Fakes
•   …
DEMO
Is unit-testing TDD?
• NO
• Test-before development
  – red / green / refactor
• Test-after development
DEMO
?

More Related Content

More from Wekoslav Stefanovski

SOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere MortalsSOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere Mortals
Wekoslav Stefanovski
 

More from Wekoslav Stefanovski (9)

Through Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.jsThrough Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.js
 
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScriptTypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
 
How to write bad code using C#
How to write bad code using C#How to write bad code using C#
How to write bad code using C#
 
Garbage Collection .Net
Garbage Collection .NetGarbage Collection .Net
Garbage Collection .Net
 
Testing your Single Page Application
Testing your Single Page ApplicationTesting your Single Page Application
Testing your Single Page Application
 
Smoke and Mirrors - Reflection in C#
Smoke and Mirrors - Reflection in C#Smoke and Mirrors - Reflection in C#
Smoke and Mirrors - Reflection in C#
 
TypeScript - Javascript done right
TypeScript - Javascript done rightTypeScript - Javascript done right
TypeScript - Javascript done right
 
Entity Framework 5 - Code First
Entity Framework 5 - Code FirstEntity Framework 5 - Code First
Entity Framework 5 - Code First
 
SOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere MortalsSOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere Mortals
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

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
 
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?
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Fake Mocking Dummy - Unit Testing in .net

  • 1. Macedonian Visual C# user group https://www.facebook.com/mkvcsug http://mkdot.net/community/mknetug/mk_vcs/default.aspx Fake Mocking Dummy Wekoslav Stefanovski swekster@gmail.com sweko@mtdot.net
  • 2. Why test software • Bugs are bad, m’kay? • Provides demonstrative proof that business requirements have been met • Reduces risk of failures (or incidents) once systems are transferred to live operation • Assures that the users for which the solution was designed are able to operate productively. – Performant – Reliable – Secure (and safe) • When to stop testing?
  • 3. Why unit test software • White – box testing • Created by people with best knowledge of the system • Unit testing promotes flexible design • Better complexity management • Automating tests lead to fearless coding • Free regression coverage
  • 4. Unit testing myths • “Testers test, developers develop” • “Its dull to write tests.” • “There’s no time to write tests.” • “We’ll write the unit tests later.” • “The code will change, so the tests will fail in the (near) future.” • “The test we wrote some time ago (probably) don’t work anymore.”
  • 5. Unit testing myths • “Unit testing is weak at finding problems that haven’t been considered.” • “It takes too much time and effort to think of all possible cases and write all those tests.” • “Methods not being easily testable” • “Not feasible for big projects” • “Not feasible for existing projects”
  • 6. Unit testing myths • “It saves money” • “It reduces the number of bugs” • “It brings a higher code quality” • “It improves performance” • “It’s easy to unit-test concurrency”
  • 7. Fakes and Stubs and Mocks, oh my • Dummy Just a placeholder object, unused and unusable • Stub A placeholder implementation, returning defaults • Fake A working, albeit trivial implementation • Mock A simulated object that mimics behavior
  • 8. How to unit test in .net • NUnit • MSTest • TestDriven • Moq • RhinoMocks • Typemock • Microsoft Fakes • …
  • 10. Is unit-testing TDD? • NO • Test-before development – red / green / refactor • Test-after development
  • 11. DEMO
  • 12. ?