Book Review: Pragmatic Unit Testing in C# With NUnit by Andrew Hunt and David Thomas with Matt Hargett

Part of: The RAM Review

According to the authors, "You don't test a bridge by driving a single car over it on a clear, calm day. Yet many programmers approach testing that same way - one pass down the middle and they call it tested." Pragmatic Unit Testing in C# with NUnit wants to change all of that. In this book, Andrew Hunt and David Thomas with Matt Hargett want to show you how to use real unit testing to make your life easier, and your software more reliable.

Pragmatic Unit Testing is 227 pages that divided into 10 chapters and four appendixes. To work with this book you will need a copy of NUnit that is available for free download. While this book features a .NET version of NUnit, there are many other languages that support a version of NUnit as well.

Chapter 1, "Introduction," begins by describing what Unit Testing is, and why one should bother with it. The basis for unit testing is that when you write a unit of code, you should test that the unit does what it is supposed to do. That is, does the code fulfill our intent? Does it do it all of the time? And can we depend on it?

Chapter 2, "Your First Unit Test," shows how you should begin to plan your test, how to test a simple method, and how to run it with NUnit. Several methods are explained such as from the command line or with the GUI. Chapter 3, "Writing Tests in NUnit," explains how to structure a unit test by first looking at the classic "Assert," which is the fundamental building block to NUnit. Also examined is the difference between test code and production code.

Chapter 4, "What to Test: The Right BICEP," looks at how to tell if the results are right. Here you will look at what kinds of things might need testing. You will examine boundary conditions, inverse relationships, cross checking and force error conditions. Chapter 5 is called "CORRECT Boundary Conditions." Because boundary conditions are such a common source of bugs, a whole chapter is devoted to it. Topics such as Conformance, ordering, range, reference, cardinality, and time become of interest.

Continued on the next page Page 1 — Page 2

Article tags

Spread the word
Bookmark and Share
Profile image for t-michael-testi

Article Author: T. Michael Testi

T. Michael Testi is software developer, a writer, and a photographer. He also blogs at PhotographyTodayNet and at All This and Everything Else.

Visit T. Michael Testi's author pageT. Michael Testi's Blog

Read comments on this article, and add some feedback of your own

Article comments

Add your comment, speak your mind

Personal attacks are NOT allowed.
Please read our comment policy.
Please preview your comment.

blogcritics lists for Nov 12, 2009

fresh articles Most recent articles site-wide

fresh comments Most recent comments site-wide

most comments Most comments in 24hrs

top writers Most prolific Blogcritics for October

top commenters Most prolific Commenters in 24 hrs