MATLAB xUnit is a unit test framework for MATLAB code. MATLAB xUnit is designed to be easy to use for MATLAB users with a wide range of experience. Users can write tests using ordinary M-files that are very simple in structure.
Important Note: MATLAB xUnit relies heavily on object-oriented language features introduced in MATLAB 7.6 (R2008a), which was released in March 2008. MATLAB xUnit functions and classes will not work in earlier MATLAB releases. In addition, writing and running tests inside packages requires MATLAB 7.7 (R008b) or later.
To use MATLAB xUnit in MATLAB, add the "xunit" folder (directory) to the MATLAB path. See the MATLAB documentation for setting the search path. (The "tests" directory contains the framework's own self-tests, and the "architecture" directory contains information about the framework architecture; these directories are not needed for using MATLAB xUnit.)
Note for users of earlier versions of MATLAB xUnit: If you have already written unit tests based on MTEST, an earlier version of MATLAB xUnit, you may also want to add the "obsolete" folder to the MATLAB path. This folder contains the old command-line test runner, mtest, as well as the deprecated function assertAlmostEqual.
Quick Start: How to Write and Run Tests
How to Put Multiple Test Cases in One M-file
How to Run Tests in Specific Directories
How to Test Using a Floating-Point Tolerance
How to Run Tests Silently and Query the Results
How to Write Tests That Share Common Set-Up Code
How to Write xUnit-Style Tests by Subclassing TestCase
How MATLAB xUnit Searches for Test Cases
Main test driver function:
Assertion functions you can use in your tests:
assertTrue
assertFalse
assertEqual
assertFilesEqual
assertElementsAlmostEqual
assertVectorsAlmostEqual
assertExceptionThrown
The key xUnit-style classes that make everything work:
TestComponent
TestSuite
TestCase
FunctionHandleTestCase
TestRunMonitor
TestRunLogger
CommandWindowTestRunDisplay
Copyright 2008-2010 The MathWorks, Inc.