Main Content

sltest.plugins.MATLABTestCaseIntegrationPlugin Class

Namespace: sltest.plugins

Add simulation and test results for MATLAB-based Simulink tests to Test Manager

Since R2020b

Description

The sltest.plugins.MATLABTestCaseIntegrationPlugin adds simulation and test results to the Test Manager test case results for MATLAB®-based Simulink® tests. A MATLAB-based Simulink test is a MATLAB code (.m) file that is derived from the sltest.TestCase class. When you add this plugin to a TestRunner object and run the simulation, these results are added to the Test Manager:

  • Test results are created for each test suite element of an sltest.TestCase class when you run the test case at the MATLAB command line.

  • By default, criteria results are added for suite element failures from the fatalAssertSignalsMatch, assertSignalsMatch, assumeSignalsMatch, and verifySignalsMatch qualification methods. A comparison run for these failures is added under the corresponding test case result. For passing comparison runs, add the matlab.unittest.plugins.DiagnosticsOutputPlugin with passing diagnostics enabled to the TestRunner.

  • In addition to adding sltest.plugins.MATLABTestCaseIntegrationPlugin to a TestRunner, if you add sltest.plugins.ModelCoveragePlugin, model coverage is collected.

Simulation results, which are created using the simulate method, are added to the corresponding test case results.

The sltest.plugins.MATLABTestCaseIntegrationPlugin class is a handle class.

Creation

To use the MATLABTestCaseIntegrationPlugin, add it to the TestRunner object:

import sltest.plugins.MATLABTestCaseIntegrationPlugin
testRunner.addPlugin...
   (sltest.plugins.MATLABTestCaseIntegrationPlugin());

Examples

collapse all

  1. Import the needed plugins and the test runner.

    import matlab.unittest.TestRunner
    import matlab.unittest.plugins.DiagnosticsOutputPlugin
    import sltest.plugins.MATLABTestCaseIntegrationPlugin
    import sltest.plugins.ToTestManagerLog
    
  2. Create a TestSuite array and basic TestRunner object for a test script file, such as one named mySltestTestCaseFile.m.

    suite  = testsuite('mySltestTestCaseFile.m');
    runner = TestRunner.withNoPlugins;
     
  3. Add a MATLABTestCaseIntegrationPlugin to the TestRunner object.

    runner.addPlugin(MATLABTestCaseIntegrationPlugin);
    
  4. Run the suite to add the failing diagnostics and simulation results to the Test Manager.

    results = runner.run(suite);
  5. Add the passing diagnostics to the Logs section of the test results in the Test Manager.

    runner.addPlugin(DiagnosticsOutputPlugin(ToTestManagerLog(),...
        'IncludingPassingDiagnostics',true));
  6. Rerun the suite to add the diagnostics and simulation results to the Test Manager.

    results = runner.run(suite);

Version History

Introduced in R2020b