How Generate Code Coverage Report in Cobertura XML Format for a .slx file

48 views (last 30 days)
Hello,currently I work with Simulink Test for Model Unit Verification. For the last step - generating the reports (coverage, tests, requirements) I need to find a way to get all these in a XML or JSON or CSV format.
For the report generated out of the test manager I learned that I can use the XMLPlugin. So this is OK.
For the coverage report I saw there is the CodeCoveragePlugin -> CoberturaFormat, but this can be applied only on *.m files and *.mlx files.
Is there a way to apply use this plugin on *.slx files? or *.mldatx? Or is there any other plugin available for my case?
Also could you please help with the following 2 questions related to the coverage report:
1. Is there a way to generate this report only for a specific unit inside the Simulink model? My test harness is created at a higher level from the unit that I am interested to verify, so when I Run the Coverage, I get the report for the entire component.
Under Model Settings/Coverage view I have selected Subsystem and then I chose the unit that I am interested in, but no result. The coverage report is still created for the entire component.
2. From where can I chose to run only the Statement coverage?
Thank you!!!

Accepted Answer

Guilherme Costa Nascimento
Hi Diana,
For Simulink models you can use the sltest.plugins.ModelCoveragePlugin. This documentation page has an example of how to do this: Model Coverage Results for Continuous Integration. Although the page is focused on continuous integration, the example works the same way when run on desktop.
Just note that the Cobertura format provides limited support to model coverage.
  • Only top model coverage is reflected in the Cobertura XML
  • Only model Decision coverage is reflected, and it is mapped to Condition elements in Cobertura XML
On your other two questions:
1. The model setting to scope the coverage results to only a particular subsystem only works when running coverage directly from Simulink. The option is not available in the Test Manager. You can use a coverage filter to exclude the components inside your harness that you do not want to include in the coverage results.
2. All code coverage metrics are computed when running a Simulink model in SIL or PIL mode. Do you need the report to only include Statement coverage?

More Answers (0)

Community Treasure Hunt

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

Start Hunting!