Main Content

Function-Based Unit Tests

Write tests using qualifications; customize test runner; select and run tests

Write function-based tests to check that the outputs of MATLAB®scripts, functions, or classes are as you expect. You can use a full library of qualification functions to produce four different types of test failures. For example, you can produce verification or fatal assertion test failures. Function-based tests subscribe to the xUnit testing philosophy.

To get started, seeWrite Function-Based Unit TestsandWrite Simple Test Case Using Functions.

For more advanced test authoring, including using test parameterization and test fixtures, consider writingClass-Based Unit Tests.

Functions

functiontests 创建数组处理本地功能的测试ons
runtests Run set of tests
testsuite Create suite of tests
testrunner Create test runner
run (TestSuite) RunTestSuitearray usingTestRunnerobject configured for text output

Classes

Test Specification of single test method
FunctionTestCase TestCase used for function-based tests
TestResult Result of running test suite

Topics

Write Tests

Run Tests and Analyze Results