3. How to Write a Unit Test
You’ve now seen what we’re trying to achieve by testing software, and how test-driven software and unit tests can help to achieve that. But how exactly is a unit test written? In this chapter you’ll see a single unit test being built from first principles. You’ll see what the different components of a test are, and how to go from a test or collection of tests to production code. The code in this chapter is not part of a project: It just shows the thought process in going from requirement to tested app code. You do not need to run the code in this chapter.
Remember, the first step in writing a unit test is to identify what the application needs to do. After I know what I need, I can decide what code ...