Write script-based tests to check that the outputs of MATLAB® scripts, functions, or classes are as you expect. For example, you
can use the assert
function to test for actual output
values that match expected values. Or you can test that the output variables
have the correct size and type. To run your test scripts use the
runtests
function.
To get started, see Write Script-Based Unit Tests.
For more advanced test authoring, including access to many different types of test qualifications, consider writing Function-Based Unit Tests or Class-Based Unit Tests.
TestResult | Result of running test suite |
This example shows how to write a live script that tests a function that you create.
This example shows how to write a script that tests a function that you create.
Write Script-Based Test Using Local Functions
This example shows how to write a script-based test that uses local functions as helper functions.
This example shows how to analyze the information returned by a test runner.
This example shows how to identify and handle failed tests.
Rerun failed tests quickly and conveniently.
Access additional functionality using script-based tests, including test selection, programmatic access of test diagnostics, and test runner customization.
Choose a test authoring scheme that best suits your requirements and your preferred workflow.