Main Content

supportsParallel

Class: matlab.unittest.plugins.Parallelizable
Namespace: matlab.unittest.plugins

Determine if plugin supports running tests in parallel

Description

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 test runner 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™.

example

Input Arguments

expand all

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

Examples

expand all

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

classdef ExamplePlugin < ...
        matlab.unittest.plugins.TestRunnerPlugin & ...
        matlab.unittest.plugins.Parallelizable

    properties (SetAccess = immutable)
        Output
    end

    methods
        function plugin = ExamplePlugin(stream)
            arguments
                stream (1,1) string = "StandardOutput"
            end
            plugin.Output = stream;
        end

        function tf = supportsParallel(plugin)
            tf = (plugin.Output == "StandardOutput");
        end
    end
end

Version History

Introduced in R2019b