This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

sltest.plugins.coverage.ModelCoverageReport class

Package: sltest.plugins.coverage

Specify model coverage report details for tests run with MATLAB Unit Test


mcr = sltest.plugins.coverage.ModelCoverageReport(path) creates mcr, a ModelCoverageReport that specifies the report folder path. Use a ModelCoverageReport to specify report properties when you run Simulink® Test™ test files run with the MATLAB® Unit Test framework.

Specify report properties before you run the test:

  1. Create a ModelCoverageReport.

  2. Create a ModelCoveragePlugin, and specify the ModelCoverageReport by using the Producing property.

  3. Add the ModelCoveragePlugin to the TestRunner.

  4. Run the test.


mcr = sltest.plugins.coverage.ModelCoverageReport(path) creates mcr, a ModelCoverageReport that specifies the report folder path.

You can also import the class, then use the name:

import sltest.plugins.coverage.ModelCoverageReport
mcr = ModelCoverageReport(path)

Input Arguments

expand all

The path of the folder in which the model coverage report is saved after the test is complete.

Example: 'results/reports/coverage/model'


collapse all

This example shows how to specify model coverage report properties when running a Simulink® Test™ test file with MATLAB® Unit Test.

To run the example, set the current folder to a writable folder.

Import the classes for the example.

import matlab.unittest.TestSuite
import matlab.unittest.TestRunner
import sltest.plugins.ModelCoveragePlugin
import sltest.plugins.coverage.ModelCoverageReport

Create a MATLAB Unit Test suite from the Simulink Test file AutopilotTestFile. Also create a test runner.

ste = testsuite('AutopilotTestFile.mldatx');
trn = TestRunner.withNoPlugins;

Create a subfolder in the current folder. Create a ModelCoverageReport object specifying the new folder.

path = './exReports/coverage';
mcr = ModelCoverageReport(path)
mcr = 
  ModelCoverageReport with no properties.

Use the Prodcing property to specify the ModelCoverageReport when creating the plugin.

mc = ModelCoveragePlugin('Producing',mcr)
mc = 
  ModelCoveragePlugin with properties:

    RecordModelReferenceCoverage: '<default>'
                 MetricsSettings: '<default>'

Coverage Report for RollAutopilotMdlRef/Roll Reference
ans = 
  TestResult with properties:

          Name: 'AutopilotTestFile > Basic Design Test Cases/Requirement 1.3 Test'
        Passed: 0
        Failed: 1
    Incomplete: 0
      Duration: 31.6241
       Details: [1x1 struct]

   0 Passed, 1 Failed (rerun), 0 Incomplete.
   31.6241 seconds testing time.


Introduced in R2018b