This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

matlab.unittest.TestSuite class

Package: matlab.unittest

Class for grouping tests to run


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.


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.


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
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


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)