Main Content

Requirements with Tests in Project

Since R2025a

Metric ID

project.mt.ComponentRequirementWithTestAverage

Description

You can use this metric to determine if each component requirement in the project is linked to at least one test. The metric returns the average percentage of implemented functional requirements in the project that link to component tests.

The Project Model Testing dashboard uses the results from this metric in the Requirements Traceability section of the dashboard, in the Requirements with Tests widget.

Requirements Traceability section showing the percentage of tests with requirements, percentage of requirements with tests, the number of requirements in components, and the number of requirements in the project

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 calculates the average by using the Requirements with Tests Distribution metric results from the components in the project.

Collection

To collect data for this metric, execute the metric engine and use getMetrics with the metric ID project.mt.ComponentRequirementWithTestAverage.

metric_engine = metric.Engine;
execute(metric_engine,"project.mt.ComponentRequirementWithTestAverage");
results = getMetrics(metric_engine,"project.mt.ComponentRequirementWithTestAverage")

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

Results

For this metric, the function getMetrics returns a metric.Result instance. Instances of metric.Result return Value as a struct with these fields:

  • Average

    • Ratios(1) — Percentage of implemented functional requirements missing links to component tests, represented as a decimal.

    • Ratios(2) — Percentage of implemented functional requirements linked to component tests, represented as a decimal.

  • EmptyResults — Number of components without requirement linkage results.

  • TotalResults — Number of components with requirement linkage results.

Compliance Thresholds

The default compliance thresholds for this metric are:

  • Compliant — 100% of requirements link to tests

  • Non-Compliant — Fewer than 100% of requirements link to tests

  • Warning — None

See Also

| | |

Topics