Main Content

supportsParallel

Class: matlab.unittest.plugins.Parallelizable
Package: matlab.unittest.plugins

Specify when plugin supports running tests in parallel

Since R2019b

Description

example

tf = supportsParallel(plugin) returns logical 1 (true) if plugin supports running tests in parallel, and returns logical 0 (false) if plugin supports running tests only in serial mode.

In certain cases, the TestRunner cannot run tests in parallel when it is extended by a plugin. Override supportsParallel to specify the circumstances in which the plugin cannot be used to run tests in parallel.

Running tests in parallel requires Parallel Computing Toolbox™.

Input Arguments

expand all

Plugin object, specified as an instance of the plugin class that subclasses the matlab.unittest.plugins.Parallelizable interface.

Examples

expand all

ExamplePlugin is a parallelizable plugin that directs text output to the screen by default. Override supportsParallel so that tests run only in serial mode when the plugin writes text output to a file.

classdef ExamplePlugin < ...
        matlab.unittest.plugins.TestRunnerPlugin & ...
        matlab.unittest.plugins.Parallelizable
    
    properties
        Output (1,1) string = "StandardOutput"
    end
    
    methods
        function plugin = ExamplePlugin(stream)
            if nargin == 1
                plugin.Output = stream;
            end
        end
        function tf = supportsParallel(plugin)
            tf = (plugin.Output == "StandardOutput");
        end
    end
end

Version History

Introduced in R2019b