Code covered by the BSD License  

Highlights from
MATLAB xUnit Test Framework

image thumbnail

MATLAB xUnit Test Framework

by

 

31 Jan 2009 (Updated )

MATLAB xUnit is a unit test framework for MATLAB code.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

MATLAB xUnit Test Framework: How to Run Tests in a Package

MATLAB xUnit Test Framework: How to Run Tests in a Package

To run all the test cases in a package, give the name of the package as an argument to runtests. Note: Running tests in a package requires MATLAB R2009a or later.

For example, suppose you are distributing a set of MATLAB files called the "ABC Toolbox." Then you could put your tests inside a package called abc_tests and run them like this:

runtests abc_tests
Test suite: abc_tests
Test suite location: Package
19-Nov-2010 14:14:36

Starting test run with 2 test cases.
..
PASSED in 0.028 seconds.

(Note that the initial "+" character in the name of the package folder on disk is not part of the package name.)

Or you could put your tests inside a subpackage called abc.tests and run them like this:

runtests abc.tests
Test suite: abc.tests
Test suite location: Package
19-Nov-2010 14:14:36

Starting test run with 2 test cases.
..
PASSED in 0.001 seconds.

You should not use a generic top-level package name such "tests" because then your package might be unintentionally combined with packages with the same name created by other people.

Back to MATLAB xUnit Test Framework

Contact us