The Art of Unit Testing
with Examples in .NET

Second edition of this book is now available

Roy Osherove

May 2009 | 320 pages | B&W
ISBN: 1933988274

$39.99 pBook + eBook (includes PDF, ePub, and Kindle)
$31.99 eBook only (includes PDF, ePub, and Kindle)
Browse all our mobile format eBooks.


 Look Inside Resources Downloads


Unit testing, done right, can mean the diff erence between a failed project and a successful one, between a maintainable code base and a code base that no one dares touch, and between getting home at 2 AM or getting home in time for dinner, even before a release deadline.

The Art of Unit Testing builds on top of what's already been written about this important topic. It guides you step by step from simple tests to tests that are maintainable, readable, and trustworthy. It covers advanced subjects like mocks, stubs, and frameworks such as Typemock Isolator and Rhino Mocks. And you'll learn about advanced test patterns and organization, working with legacy code and even untestable code. The book discusses tools you need when testing databases and other technologies. It's written for .NET developers but others will also benefit from this book.


About the Author

The chief architect at Typemock, Roy Osherove is one of the original ALT.NET organizers. He consults and trains teams worldwide on the gentle art of unit testing and test-driven development. He frequently speaks at international conferences such as TechEd and JAOO. Roy's blog is at


“Changing cultures inside organizations is never easy, and Osherove shows a number of different tools you can use when trying to drive the adoption of testing in your organizations. My own experience has shown you'll need to use combinations of many of these including finding champions, getting management buy off, and most importantly learning how to deal with the folks who become roadblocks.”
Jim Holmes, Slashdot Reviewer

“This book is very well laid out, with lots of examples (written in C#). It's a short read (under 300 pages, including indexes), and has a straightforward style that lends itself well to both the beginning programmer (or programmers from other traditions, like myself) all the way to experienced programmers who want to refresh their memory on basic concepts.”
Stuart Ainsworth, AtlantaMDF

“Roy wastes no time in showing code and explaining what it does, and succinctly so...well worth keeping handy when writing unit tests.”
Grant Palin, web analyst and developer

“A lot of the techniques and suggestions Osherove provides can't really be appreciated until you've written some tests and run into frustrations...He provides multiple ways of making code testable, and discusses the pros and cons of each.”
Michael Sonsino, DZone Reviewer

“From the initial chapter on, this book not only educates, but it truly inspires. This is one of those books that gets you ramped up to do something. Whether it is starting unit testing within your organization, or enhancing existing tests, you'll want to start right away.”
Damien White, blogging at Visoft, Inc

“...Should, in my opinion, be required reading for any team or person decided to start unit tests.”
Philippe Vialatte,

“The book is a must own, buy it.”
Tim Barcz,

“Overall, I thought the book was excellent. It's a great front to back overview of unit testing, ranging from the absolute basics, to more advanced topics like test hierarchies, writing maintainable tests, and more. I wish this book was around when I was just starting to unit test. I'm recommending it to all of my friends—beginners and veterans!”
Ryan Rivest

“As I read the book I kept finding stories I could relate to. In my attempts to apply unit testing to my own code, I experienced nearly everything Roy talks about in this book...All in all, this was one of the easiest programming books I've ever read.”
Scott Muc

The Art of Unit Testing provides a thorough, incremental introduction to writing tests as part of the programming process. Programmers looking to write their first test will find easy-to-follow instructions, while those who have been testing for a while will find ideas for refining their technique.”
—Kent Beck, Three Rivers Institute

“Beautifully crafted, detailed unit testing masterpiece. Bravo, Bravo, Bravo!”
—Mohammad Azam, Microsoft MVP, HighOnCoding

“This book tells all the truth about unit testing, even the unpleasant side of it.”
—Franco Lombardo, Molteni Informatica

“Roy knows testing.”
—Wendy Friedlander, Agile Solutions

“Unit testing, directly from theory to practice.”
—Francesco Goggi, Software Engineer

“You'll find in this book all you need to quickly get up and running with unit testing. I've enjoyed the chapter on test code organization and refactoring; and the one on making your team/company embrace unit testing. Distilled experience. My rating: 5/5”
Alessandro Gallo, author ASP.NET Ajax in Action