Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

matlab.unittest.Test class

Package: matlab.unittest
Superclasses: matlab.unittest.TestSuite

Specification of a single test method

Description

The matlab.unittest.Test class holds the information needed for the TestRunner object to be able to run a single Test method of a TestCase class. A scalar Test instance is the fundamental element contained in TestSuite arrays. A simple array of Test instances is a commonly used form of a TestSuite array.

Properties

Name

Name of the Test element.

BaseFolder

Name of the folder that contains the file defining the test content. For tests defined in packages, the base folder is the parent of the top-level package folder.

Parameterization

Row vector of parameters required for the Test. The Parameterization property contains all the parameterized data needed by the TestRunner.

SharedTestFixtures

Row vector of fixtures required for the Test. The SharedTestFixtures property contains all the fixtures specified by the SharedTestFixtures class-level attribute of the TestCase class.

Tags

Cell array of tags applied to the test element.

ProcedureName

Name of the test procedure that runs for the Test. In a class-based test, the ProcedureName is the name of the test method. In a function-based, test it is the name of the local function that contains the test. In a script-based test, it is a name generated from the test section title. Unlike the Name property, ProcedureName does not include any class or package name or information about parameterization.

Examples

expand all

Create a suite of Test objects of all test methods in the BankAccountTest class.

import matlab.unittest.TestSuite;
 
suite = TestSuite.fromClass(?BankAccountTest); 

whos suite
  Name       Size            Bytes  Class                   Attributes

  suite      1x5              1636  matlab.unittest.Test 

Each test is a matlab.unittest.Test object.

Display test method names.

{suite.Name}'
ans = 

    'BankAccountTest/testConstructor'
    'BankAccountTest/testConstructorNotEnoughInputs'
    'BankAccountTest/testDesposit'
    'BankAccountTest/testWithdraw'
    'BankAccountTest/testNotifyInsufficientFunds'
Was this topic helpful?