Main Content

Requirement with Test Case Distribution

Since R2020b

Metric ID

RequirementWithTestCaseDistribution

Description

Use this metric to count the number of requirements that are linked to tests and the number of requirements that are missing links to tests. The metric analyzes only requirements where the Type is set to Functional and that are linked to a unit with a link where the Type is set to Implements. A requirement is linked to a test 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 Requirement with Test Case 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 a 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, place your cursor over the Requirements with Tests widget.

  • Use getMetrics with the metric ID RequirementWithTestCaseDistribution.

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. The first bin includes requirements that are not linked to tests. The second bin includes requirements that are linked to at least one test.

  • BinEdges — The logical output results of the RequirementWithTestCase metric, returned as a vector with entries 0 (false) and 1 (true).

  • OverallCount — The total number of functional requirements implemented in the unit with a link where the Type is set to Implements. OverallCount is calculated as the sum of the elements in BinCounts.

  • Ratios — The ratio of requirements missing links to tests and the ratio of requirements with links to tests, returned as a vector that contains these elements:

    • Ratios(1) — Percentage of requirements missing links to model tests.

    • Ratios(2) — Percentage of requirements with links to model tests.

    Each ratio is calculated as the BinCounts value divided by the OverallCount value. For example, if 27.27% of unit requirements are missing links to tests and 72.73% of unit requirements have links to tests, Ratios returns a vector with the percentages in decimal form: [0.2727; 0.7273].

Compliance Thresholds

The default compliance thresholds for this metric are:

  • Compliant0 requirements are missing links to tests

  • Non-Compliant1 or more requirements are missing links to tests

  • Warning — None

See Also

Related Topics