Getting started: Code coverage monitoring

The Profiling and Logging perspective includes views for identifying untested lines and untested methods in your code. When you profile a run to analyze performance or thread bottlenecks, you can also monitor coverage to ensure that you have exercised all the appropriate parts of your application.

The following views are available for monitoring code coverage:

 

Parent topic

Getting started with run-time problem determination

Collecting data for coverage monitoring

Prerequisites:

To collect data:

  1. In the Profiling tab of the Profile dialog box, select the Method and Line Coverage Information profiling set. (A Method Coverage Information profiling set is also provided, but it collects only method-level coverage data for display in the Coverage Statistics view.)

  2. Click Profile to start your application. Coverage data is collected and recorded in a Method and Line Code Coverage profiling resource, which is displayed in the Profiling Navigator. After you have exercised your application, you can terminate it.

Detecting untested lines and methods

The Coverage Navigator and Annotated Source views display tested and untested lines, as well as methods. The Coverage Statistic view displays tested and untested methods.

To detect untested lines and methods:

  1. Display the Coverage Navigator and Annotated Source views: Right-click the Method and Line Code Coverage profiling resource for the data that you collected, and from the pop-up menu select Open With > Coverage Details. If these views report No data available for display, read the topic Flushing coverage data for display in the Coverage Details views.

  2. Display the Coverage Statistics view: Right-click the Method and Line Code Coverage profiling resource for the data that you collected, and from the pop-up menu select Open With > Coverage Statistics.

  3. In the Coverage Navigator view, double-click an entry to synchronize the display in the Annotated Source view, if source code is available, and in the Coverage Statistics view.

  4. Examine the views for lines that were not tested, or only partially tested.

  5. Profile your application again in such a way that these lines are tested. The coverage data is automatically merged at the host level and above with data collected in earlier runs. To display the Host profiling resource, open the Profiling Monitor drop-down menu; click the Hide Host command, if it is preceded by a checkmark, to remove the checkmark. You can now open the coverage views for the host-level profiling resource.

For additional information, read Monitoring code coverage to detect untested lines and methods.