Trade in Yours
For a £3.25 Gift Card
Trade in
Have one to sell? Sell yours here
Sorry, this item is not available in
Image not available for
Image not available

Tell the Publisher!
I’d like to read this book on Kindle

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

The Art of Unit Testing: with Examples in .NET [Paperback]

Roy Osherove
4.3 out of 5 stars  See all reviews (18 customer reviews)

Available from these sellers.

Trade In this Item for up to £3.25
Trade in The Art of Unit Testing: with Examples in .NET for an Amazon Gift Card of up to £3.25, which you can then spend on millions of items across the site. Trade-in values may vary (terms apply). Learn more
There is a newer edition of this item:
The Art of Unit Testing: with examples in C# The Art of Unit Testing: with examples in C# 3.0 out of 5 stars (1)
In stock.

Book Description

8 July 2009 1933988274 978-1933988276 1

Unit testing, done right, can mean the difference 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.

Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.

Table of Contents

  1. The basics of unit testing
  2. A first unit test
  3. Using stubs to break dependencies
  4. Interaction testing using mock objects
  5. Isolation (mock object) frameworks
  6. Test hierarchies and organization
  7. The pillars of good tests
  8. Integrating unit testing into the organization
  9. Working with legacy code

Product details

  • Paperback: 320 pages
  • Publisher: Manning Publications; 1 edition (8 July 2009)
  • Language: English
  • ISBN-10: 1933988274
  • ISBN-13: 978-1933988276
  • Product Dimensions: 1.7 x 18.4 x 23.5 cm
  • Average Customer Review: 4.3 out of 5 stars  See all reviews (18 customer reviews)
  • Amazon Bestsellers Rank: 293,989 in Books (See Top 100 in Books)

More About the Author

Discover books, learn about writers, and more.

Product Description

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

Inside This Book (Learn More)
Browse Sample Pages
Front Cover | Copyright | Table of Contents | Excerpt | Index | Back Cover
Search inside this book:

Sell a Digital Version of This Book in the Kindle Store

If you are a publisher or author and hold the digital rights to a book, you can sell a digital version of it in our Kindle Store. Learn more

What Other Items Do Customers Buy After Viewing This Item?

Customer Reviews

Most Helpful Customer Reviews
12 of 12 people found the following review helpful
4.0 out of 5 stars Fantastic for those new to Unit Testing 14 Sep 2009
I thought this book was excellent, but it came to me 6 years too late! If you're just starting out down the unit testing/TDD route then I would highly recommend you get this book and give it a read. It's broken up into 4 parts, each part building on the concepts from the previous part.

The first part sets the arena for the rest of the book by providing concise definitions of what Unit and Integration tests are, as well as introducing the reader to the concept of Test Driven Development (TDD). Part 1 ends with chapter 2 that walks the reader through an example of putting together their first unit test.

The second part then starts looking at ways of making your code loosely coupled so that you can test more effectively and start using Fake objects. Roy does this by introducing the concept of Dependency Injection (DI), otherwise known as Inversion of Control (IoC), and then how you can utilise DI to make use of Stub and Mock objects in your tests. The second part ends with the introduction of Isolation Frameworks and looks at how they can ease the complexity of using Stubs and Mocks in your Unit Tests.

The third part then starts moving in to the more practical side of Unit testing now that the groundwork has been established in the first 2 parts. Roy takes the reader through the various patterns that can be used for test classes and how you can utilise them in a Test Hierarchy. Roy highlights that a Automated Build process is essential for running your test regularly to pick up any breaking changes that may have occurred in your application. Chapter 7 then moves onto the critical area of how to write tests that are maintainable, trustworthy and readable.
Read more ›
Comment | 
Was this review helpful to you?
4 of 4 people found the following review helpful
4.0 out of 5 stars Great for New/Novice Unit Testers 21 July 2009
This is the summary taken from my full book review published here: [...]

An excellent book, I would recommend it if:

* You are completely new to Unit Testing.
* You have been Unit Testing for a short while and looking to see what the next step for you is.

If you have been a hardcore TDD practitioner for years, then I would expect that this book is not for you since you would have likely hashed all the issues covered in the book.

There are a lot of great anecdotes in the book, many of which rang home with me and personal experience. Which (for me) just affirms that the content is good.

A real nice, relatively short read. Great job Roy!
Comment | 
Was this review helpful to you?
2 of 2 people found the following review helpful
5.0 out of 5 stars New to unit testing? Check this out. 5 Nov 2009
I have been 'playing' with Unit Tests for a couple of years now, and have never felt comfortable implanting them because I knew I wasn't doing it right, I was making silly mistakes (both design and implantation), but didn't know exactly what I should be doing to resolve this.

After reading this book I have a very clear vision of what's right and what's not. I is written in a very easy-to-understand way with clear examples and well reasoned explanations. It shows the novice (and not so novice) test writer how they should go about writing clear, reliable and maintainable tests. There is some really great advice to get the reader up and running in no time at all, and best of all, with the confidence that what they are writing will stand the test of time in any development environment.

It also make very clear how to implement stubs and mocks and what rôle they play in the testing environment.

A truly great read and very highly recomended.
Comment | 
Was this review helpful to you?
1 of 1 people found the following review helpful
Format:Paperback|Verified Purchase
"The Art of Unit Testing" by Roy Osherove is a good, introductory book re. unit testing for those working with .Net, particularly for those using (or planning to use) NUnit and RhinoMocks.

It's an easy read, that goes through what makes a good unit test, how to write a simple unit test using NUnit, how to replace dependencies with manually created stubs, how to manually create mocks, then how to use a mocking framework (e.g. RhinoMocks) to dynamically creates stubs and mocks. There's useful advice on things like naming conventions, how to organise projects and folders, integrating into the build system, how to introduce unit testing into an organisation, and how to work with legacy code. There's also advice on OOD for testability, including interface driven development and use of inheritance in order to break dependencies or allow insertion of objects to allow unit testing to take place (this has been a serious mental block for some developers I have worked with in the past - not being able to recognise that, with a little re-factoring, code that they thought could only be tested using integration/system testing can have dependencies broken to allow unit testing to take place). Together with numerous links/references to other tools and materials, this is a great, easy to read, and fairly short, introduction. It's one of a short list of books that I think all .Net developers should read.

This is not, however, the complete guide to unit testing in the .Net world. For example, it touches on Inversion of Control containers (e.g. Castle Windsor) but doesn't go into any detail. It mentions patterns for unit testing, but directs the reader elsewhere for more information. It touches on Test Driven Development, but doesn't really follow it through.
Read more ›
Comment | 
Was this review helpful to you?
Would you like to see more reviews about this item?
Were these reviews helpful?   Let us know
Most Recent Customer Reviews
5.0 out of 5 stars Great Service
Great Service that was quick and easy with really good quality books. Would definitely use again as and when required.
Published 11 months ago by Mrs Judy L Jones
5.0 out of 5 stars Must-read for .NET Developers
I will not write a lengthy post about why you should read a book about Unit Testing. If you are a developer and reading these reviews, I'm quite sure you are not to be told... Read more
Published 14 months ago by Robbin Cremers
1.0 out of 5 stars Basic and light on information
I'm fairly new to unit testing but found this book really didn't help a great deal. Although not a very long book by any stretch, there is still much repetition, hideously bad... Read more
Published 17 months ago by John
4.0 out of 5 stars Good but read with caution
That is really good book about unit testing. It gives you idea why, where when and how. If you new to unit testing it is a must read, if you have some experience still you get will... Read more
Published 19 months ago by Maciej Lisman
5.0 out of 5 stars Must-Read for developers starting out with Unit Testing
As more and more job adverts are requiring understanding and experience of unit testing, I decided it was time to take the plunge and learn how to do it properly. Read more
Published on 10 April 2012 by Dave Mason
4.0 out of 5 stars Nice place to start
The book is ideal for those people new on TDD trying to figure out how to proceed. My edition have some minor errors, but it is a great reading.
Published on 20 Mar 2012 by Jordi
5.0 out of 5 stars Must read this
This book is now mandatory reading for all my development staff. They all have a copy and are expected to read and apply the wisdom within. Need I say more? Read more
Published on 6 Aug 2011 by Haughtonomous
5.0 out of 5 stars Easy on the mind
This book is an easy read. Good to get you started on unit testing. Simple on the mind as well.
Published on 18 Mar 2011 by Amazon Customer
3.0 out of 5 stars Introductory level
I have read Roy Osherove's blog now and again and found it useful over the years to develop my knowledge of unit testing. Read more
Published on 14 Mar 2011 by E. L. Wisty
3.0 out of 5 stars Not what I expected
I must admit: I expected to have a .Net equivalent of xUnit Test Patterns: Refactoring Test Code (Addison Wesley Signature) and, unfortunately, all I got was a very condensed and... Read more
Published on 6 Feb 2011 by mezastel
Search Customer Reviews
Only search this product's reviews

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
First post:
Prompts for sign-in

Search Customer Discussions
Search all Amazon discussions

Look for similar items by category