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.

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.

Examples

expand all

Show Class of a TestSuite Array

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?