Wednesday, November 16, 2011
Monday, November 07, 2011
Unit tests in Matlab
Inspired by my coworker's "Testing Seminar", I forayed into actually testing some code that I'd recently written in matlab and found the xUnit package on Matlab central.
The second essential feature to me is that xUnit supports the file-level separation of unit tests and code. The best way I think to organize your matlab code is in a package (matlab packages are just directories starting with a '+'. Their parent directory must be on the path, but not they themselves. Functionality is called with e.g. mypackage.function) and all tests in a separate directory, e.g. testMyStuff, whose parent but not itself needs to be on the path. You run the tests by specifying
runtests testMyStuff
That way, the class package itself is neatly separated from tests and can be cleanly distributed.
Subscribe to:
Comments (Atom)