Main Content

Component Tests

Since R2025a

Metric ID

slcomp.mt.ComponentTests

Description

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

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:

  • 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

    These tests can execute independently of the component and can behave differently depending on the conditions specified in the test harness. Therefore, these tests do not definitively indicate the quality of component testing.

    To see the number of tests that can execute independently of the component execution context, see Independent Tests.

Collection

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

metric_engine = metric.Engine;
execute(metric_engine,"slcomp.mt.ComponentTests");
results = getMetrics(metric_engine,"slcomp.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 the 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 for that component test.

See Also

| |

Topics