主要内容

runTestMethod

R2026b

类: matlab.unittest.plugins.TestRunnerPlugin
命名空间: matlab.unittest.plugins

扩展单个 Test 方法的运行

描述

runTestMethod(plugin,pluginData) 扩展单个 Test 方法的运行。测试框架在 runTest 方法的作用域内计算此方法。它在设置和拆解标量 TestSuite 元素(setupTestMethod 和 teardownTestMethod)之间计算此方法。

示例

输入参数

全部展开

插件,指定为 matlab.unittest.plugins.TestRunnerPlugin 对象。

Test 方法信息,指定为 matlab.unittest.plugins.plugindata.RunPluginData 对象。测试框架使用此信息来描述该插件的测试内容。

属性

Accessprotected

要了解方法的属性,请参阅方法属性。

示例

全部展开

创建一个插件并覆盖 runTestMethod 方法,以输出计算 Test 方法所用的时间。

classdef ExamplePlugin < matlab.unittest.plugins.TestRunnerPlugin
    methods (Access=protected)
        function runTestMethod(plugin,pluginData)
            tic
            runTestMethod@ ...
                matlab.unittest.plugins.TestRunnerPlugin(plugin,pluginData)
            fprintf('### %s ran in %f seconds excluding fixture time.', ...
                pluginData.Name,toc)
        end
    end
end

版本历史记录

在 R2014a 中推出