- Run below command in MATLAB 2016b for documentation:
How to publish the "matlab.unittest.TestResult" objects to a PDF report?
7 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2017 年 11 月 9 日
編集済み: MathWorks Support Team
2023 年 5 月 3 日
How to publish the "matlab.unittest.TestResult" objects to a PDF report?
I'm currently running a combination of MATLAB xUnit-style tests and Simulink Tests from a single MATLAB script using matlab.unittest.TestSuite and matlab.unittest.TestRunner. I'm running the Simulink tests this way so that I can output the results in a JUnit-style XML document using the matlab.unittest.plugins.XMLPlugin. Here's a simple example:
---------------------------------------------------------------------------
>> import matlab.unittest.TestRunner
>> import matlab.unittest.TestSuite
>> import matlab.unittest.plugins.XMLPlugin
>> import matlab.unittest.plugins.ToFile
% Creating test suite from file
>> suite = testsuite('AutopilotTestFile.mldatx');
% Creating a test runner and configuring
>> runner = TestRunner.withTextOutput;
>> xmlFile = 'some_outputs.xml';
>> plugin = XMLPlugin.producingJUnitFormat(xmlFile);
>> runner.addPlugin(plugin);
% Running tests
>> results = runner.run(suite);
---------------------------------------------------------------------------
The results variable is an object of type matlab.unittest.TestResult. The question is that I want to use sltest.testmanager.report to generate a PDF report of the results, but sltest.testmanager.report does not accept matlab.unittest.TestResult objects as arguments. It expects an object of type sltest.testmanager.ResultSet. Is there a way to convert from an array of matlab.unittest.TestResult objects to an object of type sltest.testmanager.ResultSet?
If not, how should I go about publishing the matlab.unittest.TestResult objects to a PDF?
採用された回答
MathWorks Support Team
2023 年 5 月 3 日
編集済み: MathWorks Support Team
2023 年 5 月 3 日
One solution is to create a plugin, "TestReportPlugin", that directs the "TestRunner" to produce a test result report in PDF file format. Please refer to the following link for more information on using the plugin, "TestReportPlugin":
>>web(fullfile(docroot,'matlab/ref/matlab.unittest.plugins.testreportplugin-class.html'))
Or for latest release documentation please refer to:
Adding the following lines before running the tests produces the test results report in PDF file format:
>> pdfFile = 'MyTestReport.pdf';
>> pluginPdf = TestReportPlugin.producingPDF(pdfFile,...
'IncludingPassingDiagnostics',true,'IncludingCommandWindowText',true);
>> runner.addPlugin(pluginPdf);
Also, make sure that the "TestReportPlugin" is imported.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Results, Reporting, and Test File Management についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!