WHAT'S IN THIS CHAPTER?
Generating a test harness from existing code
Making assertions about the behavior of your code
Executing custom code during test life-cycle events
Creating data-driven tests
Testing private members and code contracts
Managing lists of tests
Application testing is one of the most important parts of writing software. Research into the costs of software maintenance have revealed that a software defect can cost up to 25 times more to fix if it makes it to a production environment than if it had been caught during development. At the same time, a lot of testing involves repetitive, dull, and error-prone work that must be undertaken every time you make a change to your code base. The easiest way to counter this is to produce repeatable automated tests that can be executed by a computer on demand. This chapter looks at a specific type of automated testing that focuses on individual components, or units, of a system. Having a suite of automated unit tests gives you the power to verify that your individual components all work as specified even after making radical changes to them.
Visual Studio 2010 has a built-in framework for authoring, executing, and reporting on test cases. Originally included only in the Team System Edition of Visual Studio, many of the testing tools are now available in the Professional Edition. This means a much wider audience can now more easily obtain the benefits of automated, robust testing. This chapter focuses on creating, ...