Custom name for simulink test coverage report

1 回表示 (過去 30 日間)
Jerome Almon
Jerome Almon 2024 年 9 月 15 日
コメント済み: Jerome Almon 2024 年 9 月 16 日
Hello,
When I run my simulink test file and generate test report like in the below code, a folder is created for coverage report and it has a html file with random name like 'tp576c882a_0284_4a8b_a3b1_8ad156fb7814.html'. (the test report has a link to this coverage report file.)
...
resultNormal = testFile.run;
testReportName = ['Report_', blockName, '.pdf'];
testReportPath = fullfile(pwd, testReportName);
sltest.testmanager.report(resultNormal, testReportPath, 'Title', ['Test Report for ', blockName, ' in MIL mode.'], 'IncludeMLVersion', true, 'IncludeComparisonSignalPlots', true, 'IncludeErrorMessages', true, 'IncludeTestResults', 0, 'IncludeCoverageResult', true,'IncludeMATLABFigures', true);
Everytime I run this script, a new html file name is created and so I have to replace the old file eveytime in my git. Is there a way to set a fixed name to this html file ?
Thanks.

採用された回答

Ayush
Ayush 2024 年 9 月 16 日
Hi Jerome
I could not a way to change the name of HTML files thus generated probably because they are typically dynamically generated to ensure uniqueness and to prevent overwriting existing files, but you can rename the HTML file after the report generation process.
Here is the sample code for the same:
% Directory where the coverage report is generated
coverageDir = fullfile(pwd, 'dirName'); % Adjust this path as needed
% Get list of HTML files in the coverage directory
htmlFiles = dir(fullfile(coverageDir, '*.html'));
% Find the most recently created HTML file
[~, idx] = max([htmlFiles.datenum]);
latestHtmlFile = htmlFiles(idx).name;
% Define the new fixed name for the coverage report
fixedHtmlFileName = 'NewName.html';
% Rename the file
movefile(fullfile(coverageDir, latestHtmlFile), fullfile(coverageDir, fixedHtmlFileName));
I hope this helps!
  1 件のコメント
Jerome Almon
Jerome Almon 2024 年 9 月 16 日
Hello Ayush,
Thank you very much for your prompt reply. Your recommended approach works, but the link to the html file from the simulink test report is cut-off due to change of name of the html file. Is there a way to preserve the link so that one can go to the coverage report from the simulink test report ?
Regards,
Jerome.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResults, Reporting, and Test File Management についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by