Main Content

Component Tests in Project

Since R2025a

Metric ID

project.mt.ComponentTests

Description

You can use this metric to count the number of component tests in the project. Component tests evaluate the component design, or a part of the design, in the same execution context of the component. These tests help you assess the quality of the component.

The Project Model Testing dashboard uses the results from this metric in the Test Status section, in the Component Tests widget.

Test Status section of dashboard showing a summary of test statuses, the number of component tests, and the number of tests 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:

  • Aggregates the Component Tests metric results from the components in the project.

  • Only includes tests that directly contribute to the quality of component testing. Specifically, tests on:

    • Component models

    • Atomic subsystems

    • Atomic subsystem references

    • Atomic Stateflow® charts

    • Atomic MATLAB® Function blocks

    • Referenced models

  • Excludes tests on:

    • Libraries

    • Subsystem references

    • Virtual subsystems

Collection

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

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

Collecting data for this metric loads the model file and test result files and requires a Simulink® Test™ license.

Results

For this metric, instances of metric.Result return these properties.

  • Value — A structure that contains:

    • Count — Number of component tests in the project

  • Artifacts — An array of structures, with one structure for each component test. The structures contain the UUID, Name, ParentUUID, and ParentName values for that component test.

Compliance Thresholds

The default compliance thresholds for this metric are:

  • Compliant0 tests are missing links to requirements

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

  • Warning — None

See Also

| | |

Topics