Test Case with Requirement Distribution
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.
Supported Artifacts
This metric collects metric results for Units in the 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
Verifiesthat link to requirements where the Type is set toFunctional. 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
getMetricswith the metric IDTestCaseWithRequirementDistribution.
Collecting data for this metric loads the model file and requires a Simulink® Test™ license.
Results
For this metric, instances of metric.Result return
Value as a distribution structure with these fields:
BinCounts— A numeric vector indicating the number of tests in each category:BinCounts(1)— Number of tests not linked to requirements.BinCounts(2)— Number of tests linked to at least one requirement.
BinEdges— A cell array of descriptive labels for each bin:'Missing linked requirements'— The test is not linked to requirements in the project.'Linked to requirements'— The test is linked to at least one requirement where the link Type is set toVerifies.
OverallCount— The total number of tests, calculated as the sum of all elements inBinCounts.Ratios— A numeric vector representing the percentage of tests in each category:Ratios(1)— Percentage of tests missing links to requirements.Ratios(2)— Percentage of tests with links to requirements.
Each ratio is calculated as the
BinCountsdivided by theOverallCount.For example, if 27.27% of unit tests are missing links and 72.73% have links,
Ratiosreturns:[0.2727; 0.7273]
Compliance Thresholds
The default compliance thresholds for this metric are:
Compliant— No unit tests are missing links to requirements.Non-Compliant— One or more unit tests are missing links to requirements.Warning— None.