Provide automatic testing of m-file functions. Captures and resports test execution, failure, and errors.
Automatically collects multiple tests written in a single file into a suite of tests.
Timothy Wall (2021). MATUnit (https://www.mathworks.com/matlabcentral/fileexchange/7979-matunit), MATLAB Central File Exchange. Retrieved .
Lacks setup and teardown facilities. Code could be broken down into smaller chunks.
Very cleanly written code
In R14, each call to the command
tests = str2func(suite([mfilename '.m']));
gets the following warning:
Warning: Non-scalar arrays of function handles will continue to work in R14, but will be illegal in R15, to support parenthesis notation for invocation of function handles. To prepare for R15, and to avoid this warning, use cell arrays of function handles instead of arrays. For more information, type 'help function_handle' and see the section at the end entitled Note on Backward Compatibility.
Bug: if the name of your test suite file starts with "test" it'll recursively loop and not provide any useful results. the workaround is to name your main file something like MyTests or DSPTest.
Inspired by: Unit testing tools
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!