Page tree

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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

About Metrics

C++test 's metrics analysis calculates various metrics for your code to help you assess your code base and monitor changes. More specifically, calculating and tracking metrics helps you to:

  • Better understand code complexity and what other classes a change in the code may affect. This helps you make more informed decisions as to how to modify, refactor, and test it.
  • Identify some of the symptoms of poor design.

Calculating Metrics

To calculate metrics:

  1. Review the Built-in> Metrics Test Configuration. If you want to customize the metrics that are checked or their acceptable ranges, create a Test Configuration with your preferred metrics settings.
  2. Start the test using the preferred Test Configuration.
  3. Review and respond to the metrics calculations.
    • Project-level metrics will be reported in the UI and in reports. For more details, see Generating an XML Report with Metrics Data.
    • If you configured C++test  to report tasks for out of range metrics (by enabling the Test Configuration’s Static> Metrics tab Report tasks for metrics values out of acceptable ranges option), any out of range metrics will be reported in the Fix Static Analysis Violations category of the Quality Tasks view.
    • For details, see Reviewing and Responding to Metrics Measurements.

Generating an XML Report with Metrics Data

C++test  Server edition can generate an XML report with metrics summary information, as well as individual class and method detail data where applicable.

From the GUI

To configure XML metrics reporting from the GUI:

  • In the report preferences dialog, enable Add metric details to XML data.

From the Command Line

To configure XML metrics reporting from the command line:

  • Modify your local settings file to use the option report.metrics_details=true.

Reviewing and Responding to Metrics Measurements

This topic covers how to analyze C++test’s metrics calculations.

Sections include:

Accessing Metric Measurements

For tests run in the GUI, metric measurements are reported in the Metrics view. If this is not displayed, choose Parasoft> Show View> Metrics

 

 

For tests run from cpptestcli, metric measurements are reported in the Metrics section of the report (if the Publish metrics statistics in reports option is enabled in the Test Configuration’s Static> Metrics tab). 

In the Metrics view, you can use the project tree to determine what metrics are shown in the Metrics view (project, file, method, etc.).  When applicable (e.g., at the file level), you can expand the tree to view children.

 

 

Shortcut menu items vary based on the level of metric you are viewing. 

 

Customizing the Metrics View

You can customize the Metrics view in terms of:

  • Items shown (all items, items out of recommended ranges, extreme items, items out of standard deviation).
  • Resources shown (any resource, any resource in the same project, selected resources only, selected resource and its children).
  • Columns displayed (sum, number of items, mean, standard deviation, maximum, extreme, extreme item name).

To customize these options, click the Filters button in top  right of the Metrics view, then customize the options available in the dialog that opens.

 

 

Identifying Metrics Out of the Acceptable Range

If you configured C++test to report tasks for out of range metrics (by enabling the Test Configuration’s Static> Metrics tab Report tasks for metrics values out of acceptable ranges option), out of range metrics will be reported in the Fix Static Analysis Violations category of the Quality Tasks view.

Additionally, any metric that is outside of the recommended range will be marked in red in the Metrics view. 

 

 

For tests run from the command line interface, out of range metrics are reported in the Static Analysis section of the report. If results were sent to Team Server, results can be imported into the GUI as described in Importing Results into the UI. They will then be available in the Fix Static Analysis Violations category of the Quality Tasks view.

Reviewing an Extreme Element

For results in the Metrics view, you can focus on the class or method that is reported as an "extreme element" by right-clicking a metric name, then choosing Show extreme items from the shortcut menu.

 

 

You can then open the related file by right-clicking the element and choosing Open File.

Learning About the Available Metrics

To see the description of a specific metric, right-click it in the Test Configuration’s Static> Metrics tab, then choose View Documentation from the shortcut menu.

Customizing Metrics Settings

This topic explains how to control metrics calculation and reporting.

Metrics settings can be set in the Test Configuration’s Static> Metrics tab. You can customize options such as:

  • The types of metrics checked.
  • The acceptable range for metrics.
  • Whether metrics results are included in reports and uploaded to Team Server.
  • Whether tasks are reported when metrics are found to be outside of the acceptable range.

For details on how to change these settings, see Metrics tab.

  • No labels