Testing, testing, 1-2-3
Unit testing is a practice designed to prove your code works as designed. A good set of tests will match a functional specification. A great set of tests will do that but also account for any obvious paths of failure. To get started, let’s get our feet wet with something simple: your bank account. OK, it doesn’t have to be yours. Consider a typical transaction where you buy something at a store using your ATM card.
You visit your favorite brick-and-mortar bookstore to pick up your next excellent read in the field of software development. Let’s say you find a copy of my first book, Real World Implementation of C# Design Patterns, published by Packt. Given its status as an instant classic, you can’t resist picking up a copy at any price. You tap your card on the bookstore’s point-of-sale system and two things happen:
- The equivalent of $39.95 – which is an absolute steal by the way – is taken out of your...