Run Tests from the MATLAB Command Line

You can run one or more SystemTest™ tests from the MATLAB® command line, using the strun function. This is useful for running multiple test files as a batch or calling a test file as part of a MATLAB file.

    Note:   If you use this feature, it is a good idea to first run the test from the SystemTest desktop to verify that elements are not in an error state, and that the test will run successfully, before running it via the MATLAB command line using the strun function.

The function takes the name of your test file as a string. The test file must be on the MATLAB path, or you can specify the full path in the string.

For example, to run a test called mytest that is on the MATLAB path, use this syntax:


To run a test called mytest that is not on the MATLAB path, but is in a local directory called c:\work, use this syntax:


To run multiple tests, use a cell array of strings, as follows:

strun({'mytest' 'mytest2'})

    Note:   MATLAB will remain busy while tests are executing via the strun command. Control is returned to the MATLAB command line once all tests execute.

If the SystemTest desktop is open when strun is called, strun leaves it open. Otherwise, strun closes the desktop after the test runs.

For more information, see strun.

Was this topic helpful?