1 / 10

Mocks and Stubs

This guide explores the essential use of mocks, stubs, and test doubles in unit testing, emphasizing the importance of keeping tests free of external dependencies such as databases and networks. Learn how to manage internal dependencies while striving for high-performance tests that achieve the goal of 100-500 tests per second. We delve into various testing strategies like Inside-Out and Outside-In, and highlight tools such as Rhino Mocks and Moq. By favoring test doubles over real implementations, you will ensure robust unit tests that leave no code or requirement behind. ###

Télécharger la présentation

Mocks and Stubs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mocks and Stubs Test Doubles with and without Rhino Mocks

  2. Why do I care • About all this mocking baloney?

  3. The “Unit” in Unit Test • No External Dependencies • No Database • No Network • No Registry • No context-dependent information (config files, etc.) • Goal: 100-500/sec • BUT…what about internal dependencies?

  4. Code time!

  5. Real-World Testing Strategies • Inside-Out

  6. Real-World Testing Strategies • Outside-In

  7. Note on tools

  8. A Closer Look – Indirect Inputs • Leave no code behind! • Can we control it? • If not, STUB TIME!!!

  9. A Closer Look – Indirect Outputs • Do I care if you’re called? • Leave no requirement behind! • Favor doubles over the real deal

  10. Links et. al. • Rhino Mocks - http://www.ayende.com/projects/rhino-mocks.aspx • Moq - http://code.google.com/p/moq/ • xUnit Test Patterns - http://xunitpatterns.com/ • Me • http://jimmybogard.lostechies.com • http://feeds.feedburner.com/GrabBagOfT • http://www.lostechies.com • http://feeds.feedburner.com/LosTechies • http://twitter.com/jbogard

More Related