matlab.unittest.TestSuite class

Package: matlab.unittest

Class for grouping tests to run

Description

The matlab.unittest.TestSuite class is the fundamental interface used to group and run a set of tests in the unit test framework. The matlab.unittest.TestRunner object can only run arrays of TestSuite objects.

Construction

TestSuite arrays are created using static methods of the TestSuite class. These methods may return subclasses of the TestSuite class depending on the method call and context.

Methods

fromClassCreate suite from TestCase class
fromFileCreate TestSuite array from test file
fromFolderCreate TestSuite array from all tests in folder
fromMethodCreate TestSuite array from single test method
fromNameCreate Test object from name of test element
fromPackageCreate TestSuite array from all tests in package
fromProjectCreate test suite array from tests in project
runRun TestSuite array using TestRunner object configured for text output
selectIfSelect test suite elements that satisfy conditions
sortByFixtures Reorder test suite based on shared fixtures

Examples

collapse all

Add the matlab.unittest.TestSuite class to the current import list.

import matlab.unittest.TestSuite;

Create test suites using each method.

fileSuite    = TestSuite.fromFile('SomeTestFile.m'); 
folderSuite  = TestSuite.fromFolder(pwd);
packageSuite = TestSuite.fromPackage('mypackage.subpackage');
classSuite   = TestSuite.fromClass(?mypackage.MyTestClass); 
methodSuite  = TestSuite.fromMethod(?SomeTestClass,'testMethod');

Concatenate the suites.

largeSuite = [fileSuite, folderSuite, packageSuite, classSuite, methodSuite];

Run the full suite.

result = run(largeSuite)