Main Content

getCoverageResults

Class: sltest.testmanager.TestSuiteResult
Namespace: sltest.testmanager

Get coverage results

Syntax

covResult = getCoverageResults(result)
covResult = getCoverageResults(result,model)

Description

covResult = getCoverageResults(result) gets the coverage results that belong to the test suite results object.

covResult = getCoverageResults(result,model) gets the coverage results that belong to the test suite results object and the specified model.

Input Arguments

expand all

Test suite results to get coverage results from, specified as a sltest.testmanager.TestSuiteResult object.

Name of a model within the set of coverage results, specified as a character vector.

Output Arguments

expand all

Coverage results contained in the test suite result, returned as an array of cvdata objects. For more information on cvdata objects, see cvdata (Simulink Coverage).

Examples

expand all

% Open the model for this example
openExample('sldemo_autotrans');

% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('API Test File');
ts = createTestSuite(tf,'API Test Suite');
tc = createTestCase(ts,'simulation','Coverage Test Case');

% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_autotrans');

% Turn on coverage settings at test-file level
cov = getCoverageSettings(tf);
cov.RecordCoverage = true;

% Enable MCDC and signal range coverage metrics
cov.MetricSettings = 'mr';

% Run the test case and return an object with results data
rs = run(tf);

% Get the coverage results
cr = getCoverageResults(rs);

Version History

Introduced in R2016a