Main Content

addSimulinkTestResults

Enable pushing test results to Simulink Test Manager

Syntax

addSimulinkTestResults(runner)
addSimulinkTestResults(runner,'ExportToFile',filename)

Description

addSimulinkTestResults(runner) enables pushing test results from MATLAB® to integrate them with Simulink® Test Manager. Use addSimulinkTestResults for tests that you run using the test runner, including MATLAB-based Simulink tests and

addSimulinkTestResults adds a set of plugins to a matlab.unittest.TestRunner object. The added plugins are:

  • sltest.plugins.MATLABTestCaseIntegrationPlugin — Adds simulation and test results to the Simulink Test Manager for MATLAB-based Simulink tests.

  • sltest.plugins.TestManagerResultsPlugin — Captures Simulink Test Manager results and MATLAB test Results, and allows exporting test results from the Test Manager.

  • matlab.unittest.DiagnosticsOutputPlugin — Adds diagnostics output to the Logs section of the Test Manager. To include log information, see sltest.plugins.ToTestManagerLog.

addSimulinkTestResults(runner,'ExportToFile',filename) enables exporting test results to an MLDATX file with the specified filename. Load this file at the MATLAB command line to view the test results.

Note

addSimulinkTestResults is not supported for parallel workflows.

Input Arguments

expand all

Test runner, specified as a matlab.unittest.TestRunner object.

Name of test results file, specified as an MLDATX file.

Examples

expand all

This example shows how to enable a test runner object to push test results to the Simulink Test Manager for a MATLAB-based Simulink test, and then export the results to a data file.

Before running this example, create a test file named myTests.m. The example creates a test suite for the file, and then creates a test runner with the 'textoutput' option to output status and diagnostics to the command line. Add addSimulinkTestResults to the test runner to enable pushing the results in the Test Manager and exporting the test results to a file named testmgr_results.mldatx.

suite = testsuite('myTests');
runner = testrunner('textoutput');
addSimulinkTestResults(runner,"ExportToFile",...
   "testmgr_results.mldatx");
run(runner,suite);

Introduced in R2021a