Chapter 14: Unit Testing with the Unit Test Framework


Overview

Unit testing involves writing code to verify a system at a lower and more granular level than with other types of testing. It is used by programmers for programmers and is quickly becoming standard practice at many organizations. The Developer and Tester editions of Visual Studio Team System now include unit testing features that are fully integrated with the IDE and with other features such as reporting and source control. Developers no longer need to rely on third-party utilities, such as NUnit, to perform their unit testing, although they still have the option to use them.

In this chapter, we describe the concepts behind unit testing, why it is important, and how to create effective unit test suites. We introduce the practice of test-driven development, which involves the creation of tests before writing the code to be tested.

We introduce the syntax of writing unit tests, and you will learn how to work with Team System's integrated features for executing and analyzing those tests. We then go into more detail about the classes available to you when writing your unit tests, including the core Assert class and many important attributes. You will also see how easy it is to create data-driven unit tests, whereby a unit test is executed once per record in a data source, and has full access to that bound data.

We also describe the features Team System offers for easily accessing nonpublic members from your unit tests. In addition, you will learn how Team System enables the generation of unit tests from existing code as well as the generation of member structures when writing unit tests.

Team System also provides built-in features to support the unit testing of ASP.NET applications. You will learn how to create ASP.NET unit tests that have full access to the ASP.NET run-time context. This enables actions such as setting and reading form control values and execution of those controls' events.

Finally, we describe how Team System can help measure the effectiveness of your tests. Code coverage is the concept of observing which lines of code are used during execution of unit tests. You can easily identify regions of your code that are not being executed and create tests to verify that code. This will improve your ability to find problems before the users of your system do.



Professional Visual Studio 2005 Team System
Professional Visual Studio 2005 Team System (Programmer to Programmer)
ISBN: 0764584367
EAN: 2147483647
Year: N/A
Pages: 220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net