Main Content

sltest.plugins.ToTestManagerLog class

Package: sltest.plugins

Output stream to write text to Test Manager result Logs for MATLAB-based Simulink tests

Description

The sltest.plugins.ToTestManagerLog creates and writes a text output stream of log information to the Logs section of test results in the Test Manager for the current TestCaseResult. Use this plugin with the matlab.unittest.plugins.DiagnosticsOutputPlugin. The ToTestManagerLog plugin generates output only for MATLAB-based Simulink tests, which are derived from sltest.TestCase objects.

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

Creation

Use matlab.sltest.plugins.ToTestMangerLog() with the matlab.unittest.plugins.DiagnosticsOutputPlugin to write the diagnostics output to the Test Manager logs. For example,

runner.addPlugin(DiagnosticsOutputPlugin...
   (ToTestManagerLog());

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 test 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);
Introduced in R2020b