主要内容

runTest

R2026b

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

扩展单个 Test 元素的运行

描述

runTest(plugin,pluginData) 扩展单个 Test 元素的运行。runTest 允许您覆盖运行 TestSuite 数组中的标量 Test 元素的方法,包括创建 TestCase 实例,以及 TestMethodSetup 和 TestMethodTeardown 例程。假设测试框架完成所有脚手架设置,它将针对每个 Test 元素调用该方法一次。

示例

输入参数

全部展开

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

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

属性

Accessprotected

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

示例

全部展开

创建一个插件并覆盖 runTest 方法,以便在运行时输出 Test 元素的标签。

classdef ExamplePlugin < matlab.unittest.plugins.TestRunnerPlugin
    methods (Access=protected)
        function runTest(plugin,pluginData)
            fprintf('### Running test: %s\n',pluginData.Name)
            runTest@ ...
                matlab.unittest.plugins.TestRunnerPlugin(plugin,pluginData)
        end
    end
end

版本历史记录

在 R2014a 中推出