100 likes | 215 Vues
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. ###
E N D
Mocks and Stubs Test Doubles with and without Rhino Mocks
Why do I care • About all this mocking baloney?
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?
Real-World Testing Strategies • Inside-Out
Real-World Testing Strategies • Outside-In
A Closer Look – Indirect Inputs • Leave no code behind! • Can we control it? • If not, STUB TIME!!!
A Closer Look – Indirect Outputs • Do I care if you’re called? • Leave no requirement behind! • Favor doubles over the real deal
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