Fake Mocking Dummy - Unit Testing in .net

1,204 views

Published on

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
1,204
On SlideShare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Fake Mocking Dummy - Unit Testing in .net

  1. 1. Macedonian Visual C# user group https://www.facebook.com/mkvcsughttp://mkdot.net/community/mknetug/mk_vcs/default.aspx Fake Mocking Dummy Wekoslav Stefanovski swekster@gmail.com sweko@mtdot.net
  2. 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. 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. 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. 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. 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. 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. 8. How to unit test in .net• NUnit• MSTest• TestDriven• Moq• RhinoMocks• Typemock• Microsoft Fakes• …
  9. 9. DEMO
  10. 10. Is unit-testing TDD?• NO• Test-before development – red / green / refactor• Test-after development
  11. 11. DEMO
  12. 12. ?

×