Book Review: The Art of Unit Testing

09/27/09

Permalink 02:42:56 pm, by truewill Email , 303 words, 116 views   English (US)
Categories: Testing, Agile, C#, IoC, Quality, Books, .NET, Tools

Book Review: The Art of Unit Testing

A review of Roy Osherove’s The Art of Unit Testing with Examples in .NET

Executive summary: buy and read this book.

The good:

Chapters 7, 8, and 9 are excellent. These cover how to write good tests, how to get your organization to adopt unit testing, and how to work with legacy code. The table on p. 232 ("Team progress and output measured with and without tests") and the test-feasibility table on p. 241 are priceless.

Appendix A covers designing for testability. I’ve only skimmed the appendices, but this hits the important topics: Inversion of Control, issues with Singletons, etc.

Appendix B has great coverage of tools and frameworks related to testing, including Moq (one of my favorites).

The disappointing:

Chapter 3 generally recommends property injection over constructor injection. I don’t agree with this, but that’s open for debate. What I find glaring is the book’s failure to mention the need to check if dependencies are assigned. This is more challenging with optional dependencies injected via properties. His techniques seem prone to NullReferenceExceptions. I can understand omitting checks from example code, but I did not find a discussion of this topic in the text.

Chapter 5 contains an extended discussion of the old, verbose record-and-replay syntax in Rhino Mocks. Much less coverage is given to the new Arrange, Act, Assert (AAA) syntax.

Similarly, some examples use anonymous delegates. While this might make the material more accessible, I prefer the cleaner syntax of lambda expressions.

I came away from the early chapters with the impression that they were excessively pragmatic. (Now I’m having difficulty coming up with examples to substantiate this.) Later chapters stressed best practices, though.

Final notes:

Read the author’s blog entry on Steal My Book. Hopefully this will make you angry (not at him!) and will encourage you to purchase his book.

Comments, Pingbacks:

No Comments/Pingbacks for this post yet...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
The name truewill is composed of two other words. What is the SECOND word?

Development Central

Development Central is the blog of Bill Sorensen, a professional software developer. Much of this will relate to C#, .NET, and OOP in general.

Disclaimer
These postings are provided "AS IS" with no warranties and confer no rights.

Search

Categories

Linkblog

b2evolution

contributors

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 2

powered by b2evolution free blog software