Skip to content

runtests

miscellaneous · scripts/miscellaneous/runtests.m

: runtests ()
: runtests (directory)
: result = runtests (directory)
: [result, coverage] = runtests (…)

Recursively scan directory (default: current directory) for test files and execute them.

Files whose base name starts with "test_" are run as scripts and are deemed to pass if they run without raising an error. Other .m files are scanned for embedded %!test blocks, each of which is evaluated independently.

With no output argument, a terse PASS/FAIL listing plus a summary line is printed. With an output argument, a struct array with fields file, name, passed, message, and blockCount is returned instead of printing.

MATLAB-style calls that request a second output (for example ReportCoverageFor) forward both outputs from matlab.unittest.runtests.