Chapter 11Unit Testing
- 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 2013 has a built-in framework for authoring, executing, and reporting on test cases. This chapter focuses on creating, configuring, running, and managing a suite of unit tests as well as adding support to drive the tests from a set of data.
YOUR FIRST TEST CASE
Writing test cases is not easily automated because the test cases must mirror the ...
Get Professional Visual Studio 2013 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.