Main Content

Tests with Requirements in Project

Since R2025a

Metric ID

project.mt.ComponentTestWithRequirementAverage

Description

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

The Project Model Testing dashboard uses the results from this metric in the Requirements Traceability section of the dashboard, in the Tests with Requirements 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 Test Case with Requirement 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.ComponentTestWithRequirementAverage.

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

Collecting data for this metric loads the model file and test result files and requires a Simulink® Test™ 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 component tests missing links to implemented functional requirements, represented as a decimal.

    • Ratios(2) — Percentage of component tests linked to implemented functional requirements, 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 tests link to requirements

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

  • Warning — None

See Also

| | | | |

Topics