Create HTML coverage report from model coverage objects
creates an output
reportInfo = cvhtml(_)
reportInfo, that contains the file names and
paths for each report.
If you create a coverage report for a model reference hierarchy by using a
cv.cvdatagroup object as the
cvhtml creates a report for each
cvhtml prepends the specified
file, to each child report.
Create a Coverage Report
This example shows how to create a coverage report programmatically.
Load the model.
modelName = "slvnvdemo_cv_small_controller";
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
simIn = Simulink.SimulationInput(modelName); simIn = setModelParameter(simIn,"CovSaveSingleToWorkspaceVar","on");
Simulate the model using
simIn and extract the coverage data from the
simOut = sim(simIn); covData = simOut.covdata;
Create a coverage report by using
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"
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.
cvdo — Coverage data
cvdata object |
Coverage data, specified as a
cvdata object or
file — File name of the generated report
character array |
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.
options — Report options
Report options, specified as a character vector or string that consists of
an option from the table, an equal sign, and
To enable an option, use
To disable an option, use
To specify multiple report options, list the options in a single character vector or string separated by commas or spaces.
"-hTR=1 -bRG=0 -scm=0"
Web view mode
Include each test in the model summary
Show aggregated tests information in coverage report
Produce bar graphs in the model summary
Use two-color bar graphs
Display hit/count ratio in the model summary
Exclude execution metric details from report
Exclude fully covered model objects from report
Exclude fully covered model object details from report
Include cyclomatic complexity numbers in summary
Include cyclomatic complexity numbers in block details
Filter Stateflow® events from report
Include linked requirements in coverage report
simMode — Simulation mode
Simulation mode, specified as one of these values:
Model in Normal simulation mode
Model in software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation mode
Model reference in SIL or PIL simulation mode
Model reference in SIL or PIL simulation mode with code interface set to top model
reportInfo — Coverage report information
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.
fileName — Coverage report file name
Coverage report file name, returned as a string.
path — Coverage report file path
Coverage report file path, returned as a string.
cvdataUniqueId — Coverage data unique identifier
Coverage data unique identifier, returned as a string.
cvdataUniqueId is the
uniqueId property of the
Use the Simulink® Editor to generate a coverage report when you simulate the model:
Open the model for which you want a model coverage report.
In the Simulink Editor, in the Modeling tab, select Model Settings.
In the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.
Click Run (Coverage) to simulate the model. When the simulation completes, the coverage report opens in the Coverage Details pane.
Version HistoryIntroduced before R2006a
reportInfo output argument outputs file and path names of coverage reports
The optional output argument
reportInfo contains the file and
path names of the coverage reports, as well as the unique identifier of the
cvdata objects used to create it.
Additionally, when you create a report using a
cvhtml now prepends the file name from the
file input argument to each child report.
R2023a: Default value of Exclude fully covered model object details from report is
The default value of the Exclude fully covered model object details from
report setting is now
off. Previously, if you
wanted to see the coverage tables in the report for fully covered model objects, you
'-nFD=0' in the
when you called
cvhtml. Now you can omit this setting from