Main Content

cvhtml

Create HTML coverage report from model coverage objects

Description

cvhtml(file,cvdo) creates an HTML report of the coverage results in the cvdata or cv.cvdatagroup object cvdo with the file name file. The model must be open when you call cvhtml.

cvhtml(file,cvdo1,...,cvdoN) creates a combined report from several cvdata objects. The results from each object appear in a separate column of the HTML report. Each cvdata object must correspond to the same root model or subsystem.

cvhtml(file,cvdo1,...,cvdoN,options) creates a combined report from several cvdata objects using the report options specified by options.

cvhtml(file,cvdo,simMode) creates an HTML report for the models that have the simulation mode simMode.

reportInfo = cvhtml(_) creates an output structure array, reportInfo, that contains the file names and paths for each report.

Note

If you create a coverage report for a model reference hierarchy by using a cv.cvdatagroup object as the cvdo argument, cvhtml creates a report for each referenced model. cvhtml prepends the specified file name, file, to each child report.

Examples

collapse all

This example shows how to create a coverage report programmatically.

Load the model.

modelName = "slvnvdemo_cv_small_controller";
load_system(modelName);

The slvnvdemo_cv_small_controller model is already configured to collect coverage. To make the coverage data accessible in the MATLAB® workspace, enable the CovSaveSingleToWorkspaceVar parameter by using a Simulink.SimulationInput object.

simIn = Simulink.SimulationInput(modelName);
simIn = setModelParameter(simIn,"CovSaveSingleToWorkspaceVar","on");

Simulate the model using simIn and extract the coverage data from the Simulink.SimulationOutput object.

simOut = sim(simIn);
covData = simOut.covdata;

Create a coverage report by using cvhtml.

rptFileName = "cv_small_controller_coverage.html";
reportInfo = cvhtml(rptFileName,covData)
reportInfo = 

  struct with fields:

          fileName: "cv_small_controller_coverage.html"
              path: "/tmp/Bdoc23b_2361005_1515804/tp9ca1a71f/slcoverage-ex75072404"
    cvdataUniqueId: "107dc6e7-d9e6-43e9-9c99-74be193bab0a"

The optional reportInfo output argument displays the file and path names of the coverage report, as well as the unique ID of the cvdata object used to generate the report.

Input Arguments

collapse all

Coverage data, specified as a cvdata object or cv.cvdatagroup object.

Data Types: cvdata | cv.cvdatagroup

File name of the generated report, specified as a character array or string array. Specify the absolute path or relative path and the file name.

Report options, specified as a character vector or string that consists of an option from the table, an equal sign, and 0 or 1.

  • To enable an option, use 1.

Example: "-hTR=1"

  • To disable an option, use 0.

Example: "-sRT=0"

  • To specify multiple report options, list the options in a single character vector or string separated by commas or spaces.

Example: "-hTR=1 -bRG=0 -scm=0"

OptionDescriptionDefault

-sRT

Show report

on

-sVT

Web view mode

off

-aTS

Include each test in the model summary

on

-agT

Show aggregated tests information in coverage report

on

-bRG

Produce bar graphs in the model summary

on

-bTC

Use two-color bar graphs

on

-hTR

Display hit/count ratio in the model summary

off

-xEM

Exclude execution metric details from report

off

-nFC

Exclude fully covered model objects from report

off

-nFD

Exclude fully covered model object details from report

off

-scm

Include cyclomatic complexity numbers in summary

on

-bcm

Include cyclomatic complexity numbers in block details

on

-xEv

Filter Stateflow® events from report

off

-req

Include linked requirements in coverage report

on

Data Types: char | string

Simulation mode, specified as one of these values:

Object SpecificationDescription

"Normal"

Model in Normal simulation mode

"SIL" (or "PIL")

Model in software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation mode

"ModelRefSIL" (or "ModelRefPIL")

Model reference in SIL or PIL simulation mode

"ModelRefTopSIL" (or "ModelRefTopPIL")

Model reference in SIL or PIL simulation mode with code interface set to top model

Output Arguments

collapse all

Coverage report information, returned as a 1-by-N structure array, where N is the number of coverage reports. The structure array contains these fields.

Coverage report file name, returned as a string.

Example: "coverageReport.html"

Data Types: string

Coverage report file path, returned as a string.

Example: "C:\Documents\CovReports"

Data Types: string

Coverage data unique identifier, returned as a string. cvdataUniqueId is the uniqueId property of the cvdata object.

Example: "80ffeedf-67f1-4361-9d20-265672f1f5c6"

Data Types: string

Data Types: struct

Alternatives

Use the Simulink® Editor to generate a coverage report when you simulate the model:

  1. Open the model for which you want a model coverage report.

  2. In the Simulink Editor, in the Modeling tab, select Model Settings.

  3. In the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.

  4. Click OK.

  5. Click Run (Coverage) to simulate the model. When the simulation completes, the coverage report opens in the Coverage Details pane.

Version History

Introduced before R2006a

expand all