Main Content

sltest.testmanager.TestFile Class

Namespace: sltest.testmanager

Create or modify test file

Description

Instances of sltest.testmanager.TestFile are files that can contain test suites and test cases.

For a MATLAB®-based Simulink® test, the MATLAB code (.m) test file name corresponds to the test file (.mldatx) filename. See Test Models Using MATLAB-Based Simulink Tests for more information.

The sltest.testmanager.TestFile class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

example

obj = sltest.testmanager.TestFile(filePath) opens the sltest.testmanager.TestFile that exists with the same filename and at the specified FilePath location. If the test file does not exist at the location, a new one is created with a default test suite and test case as children of the test file. The default test case type is a baseline test case.

obj = sltest.testmanager.TestFile(filePath,mode) overwrites the existing test file if mode is set to true. The default for mode is false.

Properties

expand all

File path and name of the test file, returned as a character vector.

Example: 'C:\MATLAB\test_file.mldatx'

Attributes:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

Data Types: char

Test file description text, specified as a character vector. If the test file description text is formatted, the format tags are included in the character vector. See Create New Test File and Set the Description.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: char

Indicates if the test file has unsaved changes, returned as 0 or 1. If the value is 0, there are no unsaved changes. The value is 1 if there are unsaved changes.

Attributes:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

Data Types: logical

Indicates if test cases that are children of the test file will execute, specified as a logical value true or false.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: logical

Name of the test file without the file path and file extension, returned as a character vector.

Attributes:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

Data Types: char

Description text for why the test file was disabled, specified as a character vector. This property is visible only when the Enabled property is set to false.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: char

The requirements that are attached at the test-file level, returned as a structure.

Attributes:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

Data Types: struct

Tags to use for categorizing, specified as a character vector or string array.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse all

Create a new test file and return the test file object. Set the description to include some bold text.

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]

In the Test Manager, you can view the formatted Description text without the format tagging.

Description text in the Test Manager

Version History

Introduced in R2015b