Modify coverage settings
sltest.testmanager.CoverageSettings let you set the
values in the Coverage Settings section in a test file, test suite,
or test case.
sltest.testmanager.CoverageSettings class is a
For information on class attributes, see Class Attributes.
getCoverageSettings methods for test file, test
suite, and test case objects return an
sltest.testmanager.CoverageSettings object, which lets you access
the coverage collection and metric settings.
RecordCoverage— Enable coverage collection
Specify if the coverage collection is on or off,
for off and
true for on.
Coverage collection is enabled or disabled in the Test Manager Coverage Settings. The corresponding UI option is Record coverage for system under test.
MdlRefCoverage— Collect coverage for referenced models
Coverage collection for referenced models is enabled or disabled in the Test Manager Coverage Settings. The corresponding UI option is Record coverage for referenced models.
MetricSettings— Coverage metric setting selection
Selection of coverage settings that are enabled or disabled, specified as
a string. For the set of possible strings, see the parameter info for
CovMetricSettings in Coverage metric
settings (Simulink Coverage) and
sltest.plugins.coverage.CoverageMetrics. Coverage metric
settings can be modified only at the test file level.
Coverage metrics are enabled or disabled in the Test Manager by selecting the check boxes in the Coverage Settings section.
CoverageFilterFilename— Coverage filter to use for coverage analysis
The file name of a coverage filter file or files on the MATLAB® path, specified as a string array. The file names specify the
coverage filters that override filter files specified in the model
configuration settings. An empty value,
no coverage filter. For more information
on coverage filters, see Coverage Filtering (Simulink Coverage). The coverage filter setting
propagates down from test files to test suites and test cases, and its
results are displayed at the Result Set level.
Specify the coverage filter file name in the Test Manager, in the Coverage filter filename table of the Coverage Settings section.
% Get coverage settings object from the test file cov = getCoverageSettings(testfile); cov.RecordCoverage = true; % Enable MCDC and signal range coverage metrics cov.MetricSettings = "mr"; % Specify a coverage filter cov.CoverageFilterFilename = "covfilter.cvf";