Main Content

Test Case with Requirement Distribution

Since R2020b

Metric ID

TestCaseWithRequirementDistribution

Description

Use this metric to count the number of tests that are linked to requirements and the number of tests that are missing links to requirements. The metric analyzes only tests that run on the model or subsystems in the unit for which you collect metric data. A test is linked to a requirement 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 Test Case with Requirement 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 tests in the project that test:

    • Unit models

    • Atomic subsystems

    • Atomic subsystem references

    • Atomic Stateflow® charts

    • Atomic MATLAB® Function blocks

    • Referenced models

  • Counts only links where the Type is set to Verifies that link to requirements where the Type is set to Functional. This includes links to requirements that are not linked to the unit or are linked to other units. For each test that is linked to requirements, check that the links are to requirements that are implemented by the unit that the test runs on.

Collection

To collect data for this metric:

  • In the Model Testing Dashboard, place your cursor over the Tests with Requirements widget.

  • Use getMetrics with the metric ID TestCaseWithRequirementDistribution.

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

Results

For this metric, instances of metric.Result return the Value as a distribution structure that contains these fields:

  • BinCounts — The number of tests in each bin, returned as a vector. The first bin includes tests that are not linked to requirements. The second bin includes tests that are linked to at least one requirement.

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

  • OverallCount — The total number of tests. OverallCount is calculated as the sum of the elements in BinCounts.

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

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

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

    Each ratio is calculated as the BinCounts value divided by the OverallCount value. For example, if 27.27% of unit tests are missing links to requirements and 72.73% of unit tests have links to requirements, 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 unit tests are missing links to requirements

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

  • Warning — None

See Also

Related Topics