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, see Write Function-Based Unit Tests and Write Simple Test Case Using Functions.

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

Funktionen

functiontestsCreate array of tests from handles to local functions
runtestsRun set of tests
testsuiteCreate suite of tests
testrunnerCreate test runner
run (TestSuite)Run TestSuite array using TestRunner object configured for text output

Klassen

TestSpecification of single test method
FunctionTestCaseTestCase used for function-based tests
TestResultResult of running test suite

Themen

Write Tests

Run Tests and Analyze Results