The Art of Unit Testing: with Examples in .NET Paperback – 8 Jul 2009
Customers Who Bought This Item Also Bought
Enter your mobile number below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
Getting the download link through email is temporarily not available. Please check back later.
To get the free app, enter your mobile phone number.
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 http://www.ISerializable.comISerializable.com.
What Other Items Do Customers Buy After Viewing This Item?
Top Customer Reviews
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 ›
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!
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 ›
- Make all methods virtual
- Make all classes unsealed.
For an experienced .NET developer it is really hard to swallow.
For counter-arguments look there:
CLR Via C#: Applied .NET Framework 2.0 Programming
Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries: Conventions, Idioms, and Patterns for Reuseable .NET Libraries (Microsoft .Net Development)
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.
Most Recent Customer Reviews
Great Service that was quick and easy with really good quality books. Would definitely use again as and when required.Published on 30 Sept. 2013 by Mrs Judy L Jones
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 morePublished on 12 July 2013 by Robbin Cremers
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 morePublished on 6 April 2013 by John
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 morePublished on 10 April 2012 by Dave Mason
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
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 morePublished on 6 Aug. 2011 by Haughtonomous
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
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 morePublished on 14 Mar. 2011 by E. L. Wisty
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 morePublished on 6 Feb. 2011 by mezastel