Documentation Center

  • Trial Software
  • Product Updates

matlab.unittest.plugins.TestSuiteProgressPlugin class

Package: matlab.unittest.plugins

Plugin that outputs progress information as text

Description

The TestSuiteProgressPlugin class creates a plugin to output progress information as text. TestSuiteProgressPlugin is added to the TestRunner to show the progress of the testing to the Command Window. This plugin is used by default when you construct a test runner with TestRunner.withTextOutput.

Construction

matlab.unittest.plugins.TestSuiteProgressPlugin creates a plugin to output progress information as text.

matlab.unittest.plugins.TestSuiteProgressPlugin(stream) redirects all the text output to the output stream, stream. If you do not specify the output stream, the plugin uses the ToStandardOutput stream.

Input Arguments

stream

Location where the plugin directs text output, specified as an OutputStream.

Default: ToStandardOutput

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB® documentation.

Examples

expand all

Add Plugin to TestRunner

In your working folder, create the file ExampleTest.m containing the following test class.

classdef ExampleTest < matlab.unittest.TestCase
    methods(Test)
        function testOne(testCase)
            % test code
        end
        function testTwo(testCase)  % Test fails
            % test code
        end
         function testThree(testCase)  % Test passes
             % test code
        end
    end
end

At the command prompt, create a test suite from the ExampleTest class.

import matlab.unittest.TestRunner;
import matlab.unittest.TestSuite;
import matlab.unittest.plugins.TestSuiteProgressPlugin;

suite = TestSuite.fromClass(?ExampleTest);

Create a test runner with no plugins. This code creates a silent runner and provides you with complete control over the installed plugins.

runner = TestRunner.withNoPlugins;

Run the tests.

result1 = runner.run(suite);

No output is displayed.

Add TestSuiteProgressPlugin to the runner and run the tests.

runner.addPlugin(TestSuiteProgressPlugin);
result2 = runner.run(suite);
Running ExampleTest
...
Done ExampleTest
__________

See Also

| |

Was this topic helpful?