Main Content

sltest.plugins.TestManagerResultsPlugin class

Package: sltest.plugins

Generate enhanced test results with the MATLAB Unit Test framework


Use the sltest.plugins.TestManagerResultsPlugin class to include Test Manager results when using the MATLAB® Unit Test framework to run Simulink® Test™ files. Test Case and Test Iteration results appear in the Details field of each TestResult object.

To publish Test Manager results, configure your test file for reporting and add the TestReportPlugin and TestManagerResultsPlugin classes to the TestRunner object. Test Case and Test Iteration results appear in the Details section of the MATLAB Test Report. For more information, see Test a Model for Continuous Integration Systems.


tmr = sltest.plugins.TestManagerResultsPlugin creates a plugin object tmr that directs the TestRunner to produce an enhanced test result.

You can also import the plugin, and then use the class name to create the object:

import sltest.plugins.TestManagerResultsPlugin
tmr = TestManagerResultsPlugin

Input Arguments

expand all

Name-Value Pair Options

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'ExportToFile','myfile'

Optional file to save results in Simulink Test MLDATX format, specified as the comma-separate pair consisting of 'ExportToFile' and the file name.

You can open the MLDATX results file in the Test Manager by clicking the Import button on the toolbar.

Example: 'ExportToFile','myfile'

Example: 'ExportToFile','myfile.mldatx'


collapse all

This example shows how to include Test Manager Results in a TestResult object produced through the MATLAB Unit Test framework.

The test case creates a square wave input to a controller subsystem and sweeps through 25 iterations of parameters a and b. The test compares the alpha output to a baseline with a tolerance of 0.0046. Output that exceeds this tolerance fails the test.

1. Set the path to the test file.

testfile = 'f14ParameterSweepTest.mldatx';

2. Create the TestSuite object.

import matlab.unittest.TestSuite
suite = testsuite(testfile);

3. Create the TestRunner object.

import matlab.unittest.TestRunner
runner = TestRunner.withNoPlugins;

4. Add the TestManagerResultsPlugin to the TestRunner.

tmr = sltest.plugins.TestManagerResultsPlugin; 

5. Run the test.

results = run(runner,suite);

6. View results of 19th iteration, a test failure.

failure = results(19)
failure = 
  TestResult with properties:

          Name: 'f14ParameterSweepTest > New Test Suite 1/Iterations Parameter Sweep(ScriptedIteration=Scripted_Iteration19)'
        Passed: 0
        Failed: 1
    Incomplete: 0
      Duration: 1.2492
       Details: [1×1 struct]

   0 Passed, 1 Failed (rerun), 0 Incomplete.
   1.2492 seconds testing time.

In the Details field of the TestResult object, test Iteration results appear as a SimulinkTestManagerResults object. The SimulinkTestManagerResults object contains information such as the type of test case, the cause of the failure, and the values of the parameters that led to the failure.

ans = 
'Baseline Test'
ans = 
'Failed criteria: Baseline'
ans = struct with fields:
      parameterName: 'a'
             source: 'base workspace'
              value: 2.6000
       displayValue: '2.6'
    simulationIndex: 1

ans = struct with fields:
      parameterName: 'b'
             source: 'base workspace'
              value: 66
       displayValue: '66'
    simulationIndex: 1

Introduced in R2018b