slcoverage.MetricSelector Class
Namespace: slcoverage
Select metric criterion for coverage filter
Description
Use an object of the slcoverage.MetricSelector
class to specify metric
selection criteria for a coverage filter rule.
The slcoverage.MetricSelector
class is a handle
class.
Creation
Description
creates a metric selector object of type sel
= slcoverage.MetricSelector(type
,element
,objIndex
,outIndex
)type
for the specified
model element element
at the objective index
objIndex
and outcome index
outIndex
.
You can only create a justify rule for a metric selector. For more information about the difference between justification and exclusion, see Coverage Filtering.
For more information on the condition and decision coverage tables produced in the report, see Top-Level Model Coverage Report.
Input Arguments
type
— Metric selector type
slcoverage.MetricSelectorType.ConditionOutcome
| slcoverage.MetricSelectorType.DecisionOutcome
| slcoverage.MetricSelectorType.MCDCOutcome
| slcoverage.MetricSelectorType.RelationalBoundaryOutcome
| slcoverage.MetricSelectorType.SaturationOverflowOutcome
Metric selector type, specified as:
slcoverage.MetricSelectorType.ConditionOutcome
objects select condition metric objective outcomes.slcoverage.MetricSelectorType.DecisionOutcome
objects select decision metric objective outcomes.slcoverage.MetricSelectorType.MCDCOutcome
objects select MCDC metric objective outcomes.slcoverage.MetricSelectorType.RelationalBoundaryOutcome
objects select outcome metrics related to relational boundary outcomes.slcoverage.MetricSelectorType.SaturationOverflowOutcome
objects select outcome metrics related to saturation on integer overflow outcomes.
element
— Model element to select
handle | Simulink® ID
Model element to select, specified as a handle or the Simulink identifier of the model element.
Example: 'slcoverage_lct_bus:18'
objIndex
— Index of objective
integer
Index of the objective that you want to filter, specified as an integer.
Example: 1
outIndex
— Index of outcome
integer
Index of the outcome that you want to filter, specified as an integer.
Example: 2
Properties
ConstructorCode
— Code used to create this selector object
character array
Code used to create this selector object, returned as a character vector.
Attributes:
GetAccess | public |
SetAccess | protected |
Description
— Description of the selector
character vector
Description of the selector, returned as a character vector. Simulink Coverage™ creates the description based on the selector.
Attributes:
GetAccess | public |
SetAccess | protected |
Id
— Element identifier
Simulink ID (default) | handle
Identifier of the model element, returned as character vector of the Simulink ID or a handle.
Attributes:
GetAccess | public |
SetAccess | protected |
ObjectiveIndex
— Index of objective
integer
Index of the objective for this selector, returned as an integer.
Attributes:
GetAccess | public |
SetAccess | protected |
OutcomeIndex
— Index of outcome
integer
Index of the outcome for this selector, returned as an integer.
Attributes:
GetAccess | public |
SetAccess | protected |
Type
— Metric selector type
ConditionOutcome
| DecisionOutcome
| MCDCOutcome
| RelationalBoundaryOutcome
| SaturationOverflowOutcome
Selector type, returned as ConditionOutcome
,
DecisionOutcome
, MCDCOutcome
,
RelationalBoundaryOutcome
, or
SaturationOverflowOutcome
.
Attributes:
GetAccess | public |
SetAccess | protected |
Methods
Public Methods
allSelectors | Selectors for model or code element |
Examples
Add Metric Selector Rule to a Filter
This example shows how to select a metric and add a rule that uses that metric. In this example, you create a rule to justify an unsatisfied decision for a Saturation block.
Open the Model and Enable Coverage Analysis
Load the model into memory.
modelName = 'slvnvdemo_covfilt';
load_system(modelName);
Use a Simulink.SimulationInput
object to configure coverage for the model.
covSet = Simulink.SimulationInput(modelName); covSet = covSet.setModelParameter('CovEnable','on'); covSet = covSet.setModelParameter('CovMetricStructuralLevel','MCDC'); covSet = covSet.setModelParameter('CovSFcnEnable','on'); covSet = covSet.setModelParameter('StopTime','20'); covSet = covSet.setModelParameter('CovSaveSingleToWorkspaceVar','on'); covSet = covSet.setModelParameter('CovSaveName','covData');
Simulate the model using the SimulationInput
object as the input.
simOut = sim(covSet);
View the coverage results before applying a filter. You can access the coverage using decisioninfo
, or you can view the HTML report using cvhtml
.
covInitial = decisioninfo(covData,[modelName,'/Saturation']);
percentInitial = 100 * covInitial(1)/covInitial(2)
percentInitial = 50
cvhtml('covReportInitial',covData);
Both decisioninfo
and cvhtml
show the same result of 50% decision coverage. If you don't intend your current tests to exercise this outcome, you can justify the outcome so it is no longer reported as missing coverage.
In this example, we justify the false
decision outcome of the input > lower limit
decision objective in the Saturation block.
Justify the Missing Condition Objective
MetricSelector
objects accept the block path or the block handle as the second input. Get the block handle of the Saturation block by using getSimulinkBlockHandle
.
id = getSimulinkBlockHandle([modelName,'/Saturation']);
Because the objective being justified is a decision outcome, the first input to the metric selector constructor is slcoverage.MetricSelectorType.DecisionOutcome
. The second input is the block handle. The last two are the index of the objective to justify and the index of the outcome of that objective, respectively.
Because the input > lower limit
decision objective is the first objective for the Saturation block, its objective index is 1
. Because the false
outcome of this objective is the first outcome, its outcome index is also 1
. Therefore, the last two inputs are 1,1
.
metr = slcoverage.MetricSelector(slcoverage.MetricSelectorType.DecisionOutcome,id,1,1);
Create a filter and rule. In this case, we use the default filter mode of justify. Then add the rule to the filter using the addRule
method.
filt = slcoverage.Filter;
rule = slcoverage.FilterRule(metr,'Expected result');
filt.addRule(rule);
Save the filter to a filter file using the save
method. Then apply the filter file to the cvdata
object by assigning the filter
property to the new filter file.
filt.save('metrfilter'); covData.filter = 'metrfilter';
Re-generate the coverage results for the Saturation block using the new filtered cvdata
object.
covFiltered = decisioninfo(covData,[modelName,'/Saturation']);
percentInitial = 100 * covFiltered(1)/covFiltered(2)
percentInitial = 75
cvhtml('covReportFiltered',covData);
In the HTML report, the missing decision outcome is highlighted to indicate that it is justified. Decision coverage for the Saturation block is now 75%.
Version History
Introduced in R2017bR2020b: Justify missing coverage outcomes for individual MCDC objectives
You can use slcoverage.MetricSelectorType.MCDCOutcome
to
justify individual modified condition/decision coverage (MCDC) outcomes without
excluding the entire expression.
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)