Vous voulez voir cette page en français ? Cliquez ici.

Have one to sell? Sell yours here
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 (3 customer reviews)

Available from these sellers.


Save Up to 90% on Textbooks
Hit the books in Amazon.ca's Textbook Store and save up to 90% on used textbooks and 35% on new textbooks. 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# 5.0 out of 5 stars (1)
CDN$ 45.12
In Stock.
Join Amazon Student in Canada


Book Description

July 8 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

Special Offers and Product Promotions

  • Join Amazon Student in Canada


Customers Who Bought This Item Also Bought


Product Details


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 http://www.ISerializable.comISerializable.com.


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

4 star
0
2 star
0
1 star
0
4.3 out of 5 stars
4.3 out of 5 stars
Most helpful customer reviews
2 of 2 people found the following review helpful
5.0 out of 5 stars Very Beneficial Dec 18 2009
Format:Paperback
As a developer with moderate TDD experience, this book introduced new concepts in addition to reinforcing what I already knew about unit testing. It made me feel safer with some of the "good" techniques we already used in our unit tests in addition to making me realize potential design enhancements that can applied to both unit tests as well as production code.

I mostly liked how it is concise and straight to the point with clear examples. The author mentions a concept then directly displays a clear example followed by an explanation of the example. With less than 300 pages and a nicely organized material, this book is enjoyable and quick to read.

I truly think every developer should read this book before starting to write unit tests.

I will definitely be looking into more Manning books...
Was this review helpful to you?
2 of 3 people found the following review helpful
3.0 out of 5 stars Good for beginners July 19 2009
Format:Paperback
The book is very good for beginners, but not for those who already practise TDD on a daily basis. The book goes into AAA style of testing, but it's entirely missing BDD examples (which is unfortunate, but not a show stopper for someone who just in the beginning.
The book does go into mocking and interaction testing. As well as covers a few important things about proper maintenance of test code and how to achieve it.
Was this review helpful to you?
1 of 2 people found the following review helpful
5.0 out of 5 stars Must-Have Books for your shelf March 7 2009
Format:Paperback|Verified Purchase
It's been a long time that I have not read a book as captivating from beginning to end. Many concepts are discussed which I have not seen in any other book about unit testing such as the integration tests as well as advanced features such as Rollback for unit test on database.

This book should be in my opinion the first book to read on unit tests throughout because as I read, "light go on" occurs page after page, chapter after chapter.

I just finished reading the book and after I will have apply all the knowledge I learned and look many of references, I will surely read the book again. Like for a good movie, I wish I will see details I did not see the first time.

The author have definitely a rare talent to know how to communicate his knowledge to the same level as Steve McConnell in Code Complete.

If Roy wrote another book, I will certainly buy it with the hope that it will be as excellent as this.
Was this review helpful to you?
Most Helpful Customer Reviews on Amazon.com (beta)
Amazon.com: 4.6 out of 5 stars  47 reviews
29 of 31 people found the following review helpful
5.0 out of 5 stars Approachable Yet Thorough June 9 2009
By Mark Seemann - Published on Amazon.com
Format:Paperback
This book covers unit testing in .NET from a pragmatic, yet thourough and passionate, perspective. In brief, it covers many important dimensions of unit testing from simple "hello world" tests over the use of Stubs and Mocks to how you write maintainable test code. It also covers organizational topics such as how you introduce unit testing in an organization and how to do code reviews of tests.

Although unit testing has become somewhat synonymous with Agile practices, such as Test-Driven Development (TDD), the book never assumes that you will be using TDD. It is valuable wether you write your tests before or after your code.

Roy Osherove clearly has a lot of experience with unit testing, and he willingly shares so we can learn from his mistakes and successes. As a long-term practitioner of TDD myself, I can vouch for most of the advice imparted by this book: It is based on established patterns and best practices that the unit testing community have arrived at through years of experimentation.

Being the anal-retentive perfectionist that I am, I would have liked to see the book adopt the Pattern Language of xUnit Test Patterns: Refactoring Test Code (Addison-Wesley Signature Series), but at least the guidance of those two books are very much in harmony, even if the terminology differs.

In summary, you can say that this book is a very readable and useful introduction to unit testing. If you are a beginner to intermediate unit test developer, you should definitely read this book - and then, as you become more advanced, you should still read xUnit Test Patterns :)
18 of 20 people found the following review helpful
5.0 out of 5 stars Best book on Unit Testing - Ever July 5 2009
By BOO - Published on Amazon.com
Format:Paperback
This book is not an evolutionary book to other unit testing books out there; it's revolutionary.

First of all it's not a thinly disguised book trying to sell you on TDD (as some unit testing books that I've read are), but rather it's a book that truly lives up to it's title - the art of unit testing.

Secondly, the discussions and examples in the book take real world considerations in mind. These are not simple contrite 'Hello World' tests, or 'perfect world' sets of code. It discuss' writing tests on both green and brown field applications.

A third aspect that is truly helpful is that there is an entire section for dealing with implementing unit testing in an organization and the politics you might face while doing so. Because the book isn't biased towards a particular software discipline, tool, or language, but on the 'art' of unit testing, these are tips and tricks you can take with you anywhere.

If you found books like 'The Pragmatic Programmer' or 'The Inmates are Running the Asylum' getting you revved up to write better software, then this book will drive you to a whole new level of unit testing.

I've been doing unit testing for several years now, but it wasn't until after I read this book, that it no longer was a chore that I checked off my 'TODO' list.
9 of 9 people found the following review helpful
5.0 out of 5 stars Succinct, Pragmatic and Actionable July 19 2009
By R. Garibay - Published on Amazon.com
Format:Paperback
The Art of Unit Testing: with Examples in .NET

In short, if you want a tactical book on unit testing that distills the passion and love of an expert practitioner into a very readable yet reference-friendly text on unit testing, this is it.

If you are new to unit testing or TDD, this book will demystify the practices, tools and techniques that would otherwise take years and lots of frustration to get right.

If you are an experienced practitioner of unit testing and TDD, and are already practicing SOLID, TOOD, and BDD not just as a flavor of the week but as a way of life, this book will provide unambiguous insight into different approaches that will help you refine your existing techniques or at a minimum, validate your approach which is always valuable to any developer who has an opportunity to review his/her techniques with a seasoned master. This book will afford you that opportunity.

While the book cites excellent references for TDD and design patterns, if there is one thing that I thought was missing was a narrative- even if by way of an appendix- that ties all of the techniques covered together in an example of building the example Logger component using TDD. I understand that this book is not about TDD, but at the same time, that's like a book on scuba equipment that teaches you precisely how to pressurize your CO2 tank, keep your mask from fogging up and care and maintenance of your scuba suit not being about scuba diving.

That said, knowing Roy, it must have been painful to resist a detailed examination on TDD, but, for this book to be effective, it had to be relatively short, to the point and most of all pragmatic for it to succeed at filling the void on the topic of unit testing techniques and practices. To that end, Roy hits the mark very elegantly without being pretentious, catering to those who test first, test last or don't (yet) test at all. While I would love for everyone to pick this book up and start doing TDD today, even if you aren't yet convinced on TDD, applying these techniques to writing code that is testable, and learning how to test the right things will be an instant asset to your product, your team and your organization.
8 of 8 people found the following review helpful
4.0 out of 5 stars Best Unit Testing Book i have read to date March 17 2010
By ncage - Published on Amazon.com
Format:Paperback
Ok yes i didn't rate it at 5 stars but i think its definitely a book everyone should have on their shelf. A lot of books i read go up for sale after i'm done this won't happen to this book. Its a keeper. Don't kid yourself. Unit testing is hard especially if your working on a system that wasn't designed / architected for unit testing. This book allowed me to "start" implementing unit testing in our internal app that i thought in the past would be impossible to add unit test to. Roy does a lot show you how to break down a system (dependencies mainly) to be able to unit test it. He has great standards to start from (naming, construction, ect...). He also adds enough info about TDD (Test-Driven Development) to show the advantages but doesn't turn into a testing zealot.

That being said the book isn't perfect (reason for 4 instead of 5 stars). First he talks very briefly in the early chapters (forgot which one) about Inversion of Control containers (IOC). He talks about IOC somewhere around where he is talking about constructor injection. He then goes on to say that IOC are beyond the scope of the book. I definitely disagree with this and think a good amount of space in the book (maybe a chapter or part of a chapter) should have been taken discussing the principles of IOC and where/why/how to use it. Its an integral part of constructor injection. If its beyond the scope of a unit testing book then where does it belong? IOC is beyond the scope of the book yet a discussion on a productivity tool (resharper) is (which i have to say i didn't mind because i found it interesting)? I just think this is a big omission in this book and is the main reason for the (-1 star) and not my 2nd point i'm about to make.

Ok the 2nd thing is the author works for TypeMock. He finally tells you that in later chapters. He seems to push Typemock a wee to much i think. Yes TypeMock is definitely the best mocking framework out there. It will allow you to mock things that you generally couldn't mock with other frameworks (Static/Shared methods) but after looking at the cost its more than a little expensive. It would have helped us greatly but the licensing cost are unreasonable (especially when you compare it to the other frameworks...FREE). Anyways, back to the topic at hand. I think the author seems to push it a little to much in the book though i will have to give it to him for using RhinoMock (free) for almost all his examples in the book.
4 of 4 people found the following review helpful
5.0 out of 5 stars Great jumpstart to improving your unit tests... in any language June 9 2012
By Matthew Jessick - Published on Amazon.com
Format:Paperback
I work on a 75 programmer project in C++ and this book has had a noticible effect on the quality of our unit tests. I read the book after one year of unit testing experience. I was able to immediately clean up many of my own bad practices by taking advantage of the many years of experience related by the author in this book.

We bought half a dozen more copies for the team and you can almost see the rolling waves of more useful and maintainable unit tests fanning out wherever those books travel.

The .NET aspects are not intrusive. This book is very useful for anyone who writes unit tests in any language, but doesn't yet have 10 years of experience to know how best to do so.
Search Customer Reviews
Only search this product's reviews

Look for similar items by category


Feedback