
Professional Visual Studio 2005 (2006) [eng]
.pdf







Unit Testing
Application testing is one of the most time-consuming parts of writing software. The statistics available from research into development teams and how they operate has revealed quite staggering results. Some teams employ a tester for every developer they have. Others maintain that the testing process can be longer than the initial development. This indicates that contrary to the way development tools are oriented, testing is a significant portion of the software development life cycle. This chapter looks at a specific type of automated testing that focuses on testing individual components, or units, of a system.
Visual Studio Team System is the first version of Visual Studio that has a built-in framework for authoring, executing, and reporting on test cases. This chapter focuses on unit tests and adding support to drive the tests from a set of data. Chapter 56 covers the other types of tests that can be created, along with the various testing windows that can be used to manage the test cases and results.
Your First Test Case
Writing test cases is not easily automated, as the test cases have to mirror the functionality of the software being developed. However, at several steps in the process code stubs can be generated by a tool. To illustrate this, start with a relatively straightforward snippet of code to learn how you can go about writing test cases that fully exercise the code. Setting the scene is a Subscription class that has a private property called CurrentStatus, which returns the status of the current subscription as an enumeration value:
Public Class Subscription
Public Enum Status
Temporary
Financial
Unfinancial
Suspended

