MATLAB: Obtain Coverage Report to Publish on Jira

jiraSimulink Coveragesimulink test

Hello All I am trying to obtain Coverage report which can be published on JIRA. I would like to use test manager file (.mldatx) as all my tests are there. For that purpose I was using a blog Coverage Matlab and Jira. The issue I faced is that there is no way to add a plugin for .mldatx file in CodeCoveragePlugin. Below is my code
% Run tests======================================
% Import Plugins

% Import Plugins
import matlab.unittest.TestRunner;
import matlab.unittest.TestSuite;
import matlab.unittest.plugins.TAPPlugin;
import matlab.unittest.plugins.ToFile;
import('matlab.unittest.plugins.CodeCoveragePlugin');
import('matlab.unittest.plugins.codecoverage.CoberturaFormat');
% Disable Warnings
warning off Stateflow:Runtime:TestVerificationFailed;
warning off Stateflow:cdr:VerifyDangerousComparison;
try
% Create Test Runner
testRunnerLocal = TestRunner.withTextOutput;
if exist('testRunnerFile.tap', 'file')== 2
delete('testRunnerFile.tap');
end
% Create a TAP plugin that sends output to the file testRunnerFile.tap.
tapFile = fullfile(getenv('WORKSPACE'), 'testRunnerFile.tap');
tapPlugin = TAPPlugin.producingVersion13(ToFile(tapFile));
% Add the plugin to the test runner.
addPlugin(testRunnerLocal,tapPlugin);
% Add Coverage Plugin
coverageFile = fullfile(pwd, 'coverage.xml');
% HERE IS THE ISSUE, I tried fronFile and fromFolder
addPlugin(testRunnerLocal,CodeCoveragePlugin.forPackage('Test1.mldatx','Producing',CoberturaFormat(coverageFile)));
% Creating Test Suite
testSuite = testsuite('Test1.mldatx');
% Run the Tests
testResults = testRunnerLocal.run(testSuite);
% Display results
disp(testResults);
catch exception
disp(getReport(exception,'extended'));
exit(1);
end
exit(0);
I am also attaching my files with it for access. Please leave a suggestion how to go about it.

Best Answer

Hi Abhishek, Using 2017b, we do not support to publish the model coverage report to CI server automatically. The best practice to have code coverage report for all the tests is using Test Manager. You can get the accumulated coverage automatically from all test cases.
Here is the document talking about enable collecting coverage in Test Manager. https://www.mathworks.com/help/sltest/ug/functional-testing-and-coverage-analysis.html
In the "Coverage Results section", you can click the button under "REPORT" to open the html format model coverage report. Please see the below image for the button's location.