Getting Code Coverage for your Tests (Using NCover)

CHALLENGE

You need Code Coverage data for your Web test.

SOLUTION

Note: Test Studio has no Code Coverage capabilities, per se. Instead, we integrate our product with NCover, which is a .NET Code coverage tool. NCover is distributed under proprietary license separately from Test Studio. Visit NCover.com for more information.

 

In order to get Code Coverage for an application, NCover and your IIS server (that hosts the application) need to be on the same machine. First, launch the NCover explorer and start a new project. Click "Application Options".

 

 

Go to the "Project Settings" tab. Set up the project to monitor your IIS server. Uncheck "Cover an application" and check "Cover a service". Set the radiobox to IIS.

 

 

You can also set the Runtime Includes/Excludes from the the Project Settings menu (in the Navigation Bar on the left). By defining Runtime Includes/Excludes, you can get Code Coverage for specific applications only. If you leave this blank, NCover will monitor all applications on your IIS server.

 

Close the Settings menu and click on the "Run Coverage" button from the main menu. 

 

 

NCover will restart your IIS server in order to get ready to monitor it. The NCover Output console should look like this once you're ready to start testing:

 

Stopping Service 'World Wide Web Publishing Service'...
Starting Service 'World Wide Web Publishing Service'...
The profiler will not connect until you load an ASP.NET page.

 

Accessing your application in any way (not just through a web test) will now generate code coverage data. At this point you can execute your web test. After you stop the coverage ("Stop Coverage" button) from the NCover explorer, detailed Code Coverage data for your application will be generated:

 

 

This is a basic example for using NCover with Test Studio. In order to ensure your questions on NCover are addressed by the appropriate resource and company, all questions specific to the NCover product should be addressed directly to NCover’s support team.