Test Case with Requirement Distribution
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
This metric returns the result as a distribution of the results of the
Analyzes only tests in the project that test:
Atomic subsystem references
Atomic Stateflow® charts
Atomic MATLAB® Function blocks
Counts only links where the Type is set to
Verifiesthat 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.
To collect data for this metric:
In the Model Testing Dashboard, place your cursor over the Tests with Requirements widget.
getMetricswith the metric ID
Collecting data for this metric loads the model file and requires a Simulink® Test™ license.
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 an integer 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
TestCaseWithRequirementmetric, returned as a vector with entries
OverallCount— The total number of tests.
OverallCountis calculated as the sum of the integers in
Ratios— The ratio of tests missing links to requirements and the ratio of tests with links to requirements, returned as an integer 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
BinCountsvalue divided by the
OverallCountvalue. For example, if 27.27% of unit tests are missing links to requirements and 72.73% of unit tests have links to requirements,
Ratiosreturns an integer vector with the percentages in decimal form:
The default compliance thresholds for this metric are:
0unit tests are missing links to requirements
1or more unit tests are missing links to requirements