MATLAB Answers

How can I extract code coverage metrics from a code coverage report?

2 views (last 30 days)
Can I get the summary data extracted from a code coverage report?
I need the data to use it in another report. Is there a way to get just the metrics from the report?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Oct 2021
Edited: MathWorks Support Team on 26 Oct 2021
In order to achieve that you need to first create a test object.
>> testObj = cvtest(model);
Then you have to run code coverage on the model.
>> [cvdo,simOut] = cvsim(testObj);
Then you can get the coverage results by using the following functions:
>> blk_handle = get_param([model], 'Handle');
>> executionCoverage = executioninfo(cvdo, blk_handle);
>> conditionCoverage = conditioninfo(cvdo, blk_handle);
>> decisionCoverage = decisioninfo(cvdo, blk_handle);
>> mcdcCoverage = mcdcinfo(cvdo, blk_handle);
You can refer to the attached script which accomplishes the above workflow.
Please follow the documentation link below to automate additional coverage workflows:

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!