Main Content

supportsParallel

クラス: matlab.unittest.plugins.Parallelizable
パッケージ: matlab.unittest.plugins

どのような場合にプラグインがテストの並列実行をサポートするかの指定

R2019b 以降

説明

tf = supportsParallel(plugin) は、plugin がテストの並列実行をサポートする場合は logical 1 (true) を返し、plugin が逐次モードでのみテストの実行をサポートする場合は logical 0 (false) を返します。

特定の状況では、TestRunner がプラグインで拡張されている場合はテストを並列実行できません。supportsParallel をオーバーライドし、プラグインを使用してテストを並列実行できないように指定します。

テストを並列実行するには Parallel Computing Toolbox™ が必要です。

入力引数

すべて展開する

プラグイン オブジェクト。matlab.unittest.plugins.Parallelizable インターフェイスをサブクラス化するプラグイン クラスのインスタンスとして指定します。

すべて展開する

ExamplePlugin は、既定でテキスト出力を画面に送信する並列化可能プラグインです。プラグインがテキスト出力をファイルに書き込む場合にテストが逐次モードでのみ実行されるように、supportsParallel をオーバーライドします。

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

バージョン履歴

R2019b で導入