Main Content

本页采用了机器翻译。点击此处可查看英文原文。

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。如果该位置不存在测试文件,则创建一个新的测试文件,并使用默认测试套件和测试用例作为测试文件的子文件。默认测试用例类型是基线测试用例。

如果 mode 设置为 true,则 obj = sltest.testmanager.TestFile(filePath,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 中推出