主要内容

sltest.testmanager.TestFile 类

命名空间: sltest.testmanager

创建或修改测试文件

描述

sltest.testmanager.TestFile 的实例是可以包含测试套件和测试用例的文件。

对于基于 MATLAB® 的 Simulink® 测试,MATLAB 代码 (.m) 测试文件名与测试文件 (.mldatx) 的文件名相对应。有关详细信息,请参阅使用基于 MATLAB 的 Simulink 测试的测试模型

sltest.testmanager.TestFile 类是一个 handle 类。

类属性

HandleCompatible
true

有关类属性的信息,请参阅类属性

创建对象

描述

obj = sltest.testmanager.TestFile(filePath) 打开指定 FilePath 位置处且文件名相同的已有 sltest.testmanager.TestFile。如果该位置处不存在该测试文件,则会创建一个新测试文件,该新测试文件中包含默认的测试套件和测试用例作为其子项。默认测试用例类型为基线测试用例。

示例

obj = sltest.testmanager.TestFile(filePath,mode)mode 设置为 true 时覆盖现有测试文件。mode 的默认值为 false

属性

全部展开

测试文件的文件路径和名称,以字符向量形式返回。

示例: 'C:\MATLAB\test_file.mldatx'

属性:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

数据类型: char

测试文件描述文本,指定为字符向量。如果测试文件描述文本包含格式设置,则格式标记会包含在该字符向量中。请参阅创建新测试文件并设置描述

属性:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

数据类型: char

指示测试文件是否有未保存的更改,返回为 0 或 1。如果值为 0,表示没有未保存的更改。如果有未保存的更改,则值为 1

属性:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

数据类型: logical

指示作为测试文件的子项的测试用例是否将执行,指定为逻辑值 truefalse

属性:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

数据类型: logical

测试文件的名称(不含文件路径和文件扩展名),以字符向量形式返回。

属性:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

数据类型: char

解释测试文件为何被禁用的描述文本,指定为字符向量。仅当 Enabled 属性设置为 false 时,此属性才可见。

属性:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

数据类型: char

附加在测试文件级别的需求,以结构体形式返回。

属性:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

数据类型: struct

用于分类的标记,指定为字符向量或字符串数组。

属性:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

数据类型: char | string

方法

全部展开

示例

全部折叠

创建一个新测试文件并返回测试文件对象。设置描述以添加一些粗体文本。

tf = sltest.testmanager.TestFile...
   ('C:\testfiles\SampleTestFile.mldatx');
tf = 
  TestFile with properties:

            Name: 'SampleTestFile'
        FilePath: 'C:\testfiles\SampleTestFile.mldatx'
           Dirty: 0
    Requirements: [0×1 struct]
     Description: ''
         Enabled: 1
            Tags: [0×0 string]
tf.Description = ...
   '<b>Baseline Test</b> created 12 September 2021'
tf = 

  TestFile with properties:

            Name: 'SampleTestFile'
        FilePath: 'C:\testfiles\SampleTestFile.mldatx'
           Dirty: 1
    Requirements: [0×1 struct]
     Description: '<b>Baseline Test</b> created 12 September 2021'
         Enabled: 1
            Tags: [0×0 string]

在测试管理器中,您可以查看格式化的描述文本,且不会显示格式标记。

Description text in the Test Manager

版本历史记录

在 R2015b 中推出