Classes, How-tos and Examples.

## Update History

### R2013a

First introduced

• matlab.unittest package, an xUnit-style testing framework for the MATLAB language that allows writing and running unit tests, and analyzing test results

New MATLAB Unit Testing Framework (9 min, 24 sec)

For information about the matlab.unittest package, see Unit Testing Framework.

### R2013b

Updated

• Functions for writing, executing, and verifying tests using the matlab.unittest testing framework without creating custom classes

As an alternative to writing object-oriented tests, the MATLAB xUnit-style testing framework now provides function-based writing, execution, and verification of tests. For more information, see Unit Testing Framework. For an example of function–based test writing, see Write Simple Test Case Using Functions.

• New fixture and plugin features for matlab.unittest testing framework

The matlab.unittest testing framework now provides four customized fixtures to ease the creation of setup and teardown code. You can use these fixtures to change the current working folder, add a folder to the MATLAB path, suppress the display of warnings, and create a temporary folder. For more information, see matlab.unittest.fixtures.

To share these fixtures across test classes, use the new SharedTestFixtures class attribute of TestCase. The getSharedTestFixtures method of TestCase provides access to the shared fixtures. You also can use fixtures within a test function by calling the applyFixture method of TestCase.

To pause execution of a test and enter debug mode upon a failure or uncaught error, you can add the new plugin, StopOnFailuresPlugin to the test runner. For more information, see matlab.unittest.plugins.

Improved

## Unit Testing Framework 单元测试框架

Write and run tests for MATLAB® programs

• Write Unit Tests 编写单元测试
Assemble test methods into test-case classes
将各个测试方法组合成测试用例类

• Run Unit Tests 运行单元测试
Run test suites in the testing framework
在测试框架中运行测试用例集

• Analyze Test Results 分析测试结果
Use test results to identify failures
使用测试结果来分析程序

## Write Unit Tests 编写单元测试

Assemble test methods into test-case classes

The matlab.unittest package is an xUnit-style, unit-testing framework for MATLAB®. To test a MATLAB program, write a test case using qualifications, which are methods for testing values and responding to failures. The test case contains test functions and test fixtures (setup and teardown code).
matlab.unittest包是xUnit风格的matlab程序测试框架。

## Run Unit Tests 运行单元测试

Run test suites in the testing framework

## Analyze Test Results 分析测试结果

Use test results to identify failures