Main Content

Test Cases per Requirement Distribution

Since R2020b

Metric ID

TestCasesPerRequirementDistribution

Description

This metric returns a distribution of the number of tests linked to each requirement. Use this metric to determine if requirements are linked to a disproportionate number of tests. The metric analyzes only requirements where the Type is set to Functional and that are linked to the unit with a link where the Type is set to Implements. A test is linked to a requirement if it has a link where the Type is set to Verifies.

This metric returns the result as a distribution of the results of the Test Cases per Requirement metric.

Supported Artifacts

You can collect this metric for the Units in your project. To control what the dashboard classifies as a unit, see Categorize Models in Hierarchy as Components or Units.

Computation Details

The metric:

  • Analyzes only requirements where the Type is set to Functional and that are linked to the unit with a link where the Type is set to Implements.

  • Counts links to tests in the project where the link type is set to Verifies, including links to tests that test other models or subsystems. For each requirement that is linked to tests, check that the links are to tests that run on the unit that implements the requirement.

Collection

To collect data for this metric:

  • In the Model Testing Dashboard, view the Tests per Requirement widget.

  • Use getMetrics with the metric ID TestCasesPerRequirementDistribution.

Collecting data for this metric loads the model file and requires a Requirements Toolbox™ license.

Results

For this metric, instances of metric.Result return Value as a distribution structure that contains these fields:

  • BinCounts — The number of requirements in each bin, returned as a vector.

  • BinEdges — Bin edges for the number of tests linked to each requirement, returned as a vector. BinEdges(1) is the left edge of the first bin, and BinEdges(end) is the right edge of the last bin. The length of BinEdges is one more than the length of BinCounts.

The bins in the result of this metric correspond to the bins 0, 1, 2, 3, and >3 in the Tests per Requirement widget.

Compliance Thresholds

This metric does not have predefined thresholds. Consequently, the compliance threshold overlay icon appears when you click Uncategorized in the Overlays section of the toolstrip.

See Also

Related Topics