Configuring Code Coverage

Visual Studio Premium or Visual Studio Ultimate can gather code coverage data when it runs tests, and it presents this data to you in different ways, statistically and graphically. You can change certain aspects of the way code coverage data is gathered and displayed.

Gathering Code Coverage Data

To obtain code coverage data, the assembly being tested must first be instrumented. You can choose whether to have assemblies instrumented in their original folder, or in the folder to which they are deployed for testing. If you are working with signed assemblies, you can make decisions about the re-signing that occurs after they are instrumented on the Code Coverage page of the test settings editor, as described in Instrumenting and Re-Signing Assemblies.

Display of Code Coverage Data

Data that is presented statistically is displayed in the Code Coverage Results window. For more information, see "Viewing Code Coverage Data" in How to: Obtain Code Coverage Data.

Graphical presentation displays lines of code that have been exercised in a different color than lines of code that have not been exercised. You can choose to enable source-code coloring by default in the Options dialog box when you open it on the Tools menu of Visual Studio. To find this setting, look on the Test Execution page under the Test Tools node. You can also change the colors that are used to show code coverage. For more information, see the section "Changing the Display of Code Coverage Data" in How to: Obtain Code Coverage Data.

64-bit processes

You can now run tests and collect code coverage information as a 64-bit process. For more information, see How to: Run a Unit Test as a 64-bit Process.

How to: Obtain Code Coverage Data

Instrumenting and Re-Signing Assemblies