Learn more Shop now Learn more Shop now Shop now Shop now Learn More Shop now Shop now Learn more Shop Fire Shop Kindle Learn More Shop now Fitbit

There was a problem filtering reviews right now. Please try again later.

VINE VOICEon 9 April 2012
"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. Even so, it's still a very useful book.

I would like to see an update to cover areas such as integrating NUnit with VS2010 and TFS, so that users of NUnit get the full advantages of the Test Impact Analysis, Code Coverage Analysis etc that is possible with VS2010. But, although that's important, this is still a good book.

Highly recommended.
0Comment| 2 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 14 September 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.

The final part is aimed at the the devs out there who are coming from existing organisations that don't do Unit Testing, but want to introduce it, or have started Unit Testing in their new app, but want to start Unit Testing their legacy code. Roy provides some good pointers on how to get Unit Testing accepted by teams less than eager to pursue new practices :)

The book also contains 2 appendices, one attempts to answer the question of how much testing should influence the design process and the second provides a good overview of the Isolation Frameworks, Tools and Test Frameworks currently available to make your life a little bit easier when you're testing.


If you're looking for a good book to get yourself, your fellow developers or team up to speed with good Unit Testing practices, then I'd highly recommend this book. If however you're a TDD guru, or have been unit testing for a while you probably won't get as much out of this as those who are new to Unit Testing.
0Comment| 13 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 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!
0Comment| 6 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 5 November 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.
0Comment| 3 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 6 April 2013
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 jokes and a lot of self-promotion. (We get it - the author thinks very highly of himself and would like to be a comedian.)

I would have preferred to read more about good TDD practices. No doubt the author knows his subject, but this book is really poor. The only thing I took from it was a good naming convention for unit tests. That was useful but not enough to warrant a whole book.
0Comment| 2 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 12 February 2013
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 something new. Alas the author gives you some guidelines which seem to be taken straight from java, two examples:
- 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)
0Comment| One person found this helpful. Was this review helpful to you?YesNoReport abuse
on 10 April 2012
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.

I had done some testing that I used to describe as unit testing (but I now understand was in fact Integration Testing) but had always really been left to fumble around in the dark when it comes to best practices.

This book was highly recommended by other reviewers on Amazon and I'm pleased to say I entirely concur. It takes you from the very basics of a unit test (the kind of practically useless stuff you find all over the internet), but then develops the idea and applies it practically using NUnit (though it does tip it's hat to other unit testing frameworks).

It then goes on to more advanced topics such as Mocks, Stubs and Dependency Injection, as well as going through various tools and techniques for achieving these.

Crucially, since completing this book I've been able to set up a raft of unit tests for an existing project that have allowed the rest of my team to make changes to a complicated system with confidence. It also uncovered a number of bugs in the system that would otherwise have gone unnoticed.

In short, this is a must-read for any developer that wants to be able to write suites of unit tests for their applications with confidence that they're doing things properly.

It's worth noting that this book is very much for developers starting out in unit testing. More advanced topics such as Inversion of Control Containers and Test Driven Development are mentioned but not really described in much detail.
0Comment|Was this review helpful to you?YesNoReport abuse
on 8 June 2010
As this is already the de facto book on unit testing for .NET developers, then it's pretty much advised that any .NET developer owns a copy. Its chief merit is that it concisely covers the evolution and practical use of unit testing in software development, including the use of mocking and testing frameworks (with specific emphasis on Rhino Mocks and NUnit). While not strictly about TDD it does give enough information to make reasonable inroads. For those new to unit testing (including myself) it will tell you how we got to here and where 'here' is.

I knew very little about formal unit testing before reading this and only purchased it because it's a common job requirement at the moment. However after reading it, I have realised that this isn't the sort of thing that professional developers can afford not to be aware of. The emphasis on .NET allows the book to be less abstract (the contextual explanations are short and to the point) and easier to put into practice.

My only gripe is that it's not quite prescriptive enough - although I suspect that's more to do with the stage of maturity that unit testing is at, rather than the author. It's not that I like to be spoon fed, but when it comes to methodologies I prefer not to have an array of options - I want to be told 'do it this way!'. That said, it does encourage you down the best practice route with adequate explanation of the pros and cons of particular techniques.

The only other thing I would say is that while it does assume a rudimentary working knowledge of OOP principles - reading a design patterns book will probably help - the examples are clear enough to work through without an external text.
0Comment|Was this review helpful to you?YesNoReport abuse
on 6 August 2011
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?

The sections on writing testable code, and how to test 'untestable' (legacy) code have proved invaluable. We now don't write or fix anything without supporting unit tests, and the regression rate of new releases has plunged. In fact when we release code to our formal testers, regression has gone from being a routine expectation to being unexpected and annoying.
0Comment|Was this review helpful to you?YesNoReport abuse
on 12 July 2013
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 anymore.

This book is ideal for people with little knowledge about unit testing, to learn the ideas and principles about unit testing. The author might sometimes sell a bit too much for his own product, nevertheless, it's still a good and readable book.
0Comment|Was this review helpful to you?YesNoReport abuse

Sponsored Links

  (What is this?)