Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

run

类: matlab.unittest.TestSuite
包: matlab.unittest

使用配置为文本输出的 TestRunner 对象运行 TestSuite 数组

语法

result = run(suite)

说明

result = run(suite) 使用配置为文本输出的 TestSuite 对象运行 suite 定义的 TestRunner 对象。

输入参数

suite

测试集,指定为 matlab.unittest.TestSuite 数组。

输出参数

result

包含测试运行结果的 matlab.unittest.TestResult 对象。result 的大小与 suite 的大小相同,并且每个元素都是 suite 中的对应元素的结果。

示例

全部展开

matlab.unittest 类添加到当前导入列表。

import matlab.unittest.TestRunner
import matlab.unittest.TestSuite

创建测试套件和测试运行程序。

suite = TestSuite.fromClass(?mypackage.MyTestClass);
runner = TestRunner.withTextOutput;

以下测试结果是相同的。

result = runner.run(suite)
result = run(suite)

提示

  • 这是一个方便的方法,等同于使用基于 TestRunner.withTextOutput 方法创建的 TestRunner 对象来运行 suite