MATLAB: How to publish the “matlab.un​ittest.Tes​tResult” objects to a PDF report

MATLABmatlab.unittest.testresultpdf

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?

Best Answer

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":
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.