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