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.







Article comments