This topic explains how to use C++test to calculate metrics. Sections include:

About Metrics

C++test 's metrics analysis calculates various code metrics, such as code complexity, coupling between objects, and lack of cohesion, to help you assess your code base and monitor changes. More specifically, calculating and tracking metrics helps you to:

Run the Metrics built-in test configuration during analysis to execute metrics analysis rules.

Reviewing Metrics Results

Metrics analysis results are available on DTP server; see Connecting to Development Testing Platform for information how to connect with DTP. Metrics results are not included in local HTML or XML reports generated by C++test.

Customizing Metrics Settings

You can configure metrics using Metrics tab in the DTP test configuration interface. 

  1. In DTP, choose Test Configurations from the gear icon menu.
  2. Click on a test configuration and click the Metrics tab to customize metrics and view metrics documentation. 

See the Development Testing Platform manual for details. 

Setting Metrics Thresholds

You can set upper and lower boundaries so that a static analysis violation is reported if a metric is calculated outside the specified value range. For example, if you want to restrict the number of logical lines in a project, you could configure the Metrics test configuration so that a violation is reported if the Number of Logical Lines metric exceeds the limit. 

The Metrics test configuration shipped with C++test includes default threshold values. There are some rules, such as Number of Files (METRIC.NOF), for which thresholds cannot be set. 
Metric thresholds can be set using the following methods: 

Built-in Metrics

The following metrics are available: