Unit Testing
33
Write Test Using Live Script ....................... 33-3Write Script-Based Unit Tests ..................... 33-6Write Script-Based Test Using Local Functions...... 33-13Extending Script-Based Tests..................... 33-17
Test Suite Creation........................... 33-17
Test Selection............................... 33-18
Programmatic Access of Test Diagnostics .......... 33-19
Test Runner Customization..................... 33-19Run Tests in Editor............................. 33-21Write Function-Based Unit Tests.................. 33-25
Create Test Function......................... 33-25
Run the Tests ............................... 33-28
Analyze the Results.......................... 33-28Write Simple Test Case Using Functions............ 33-30Write Test Using Setup and Teardown Functions ..... 33-35Extending Function-Based Tests.................. 33-42
Fixtures for Setup and Teardown Code............ 33-42
Test Logging and Verbosity ..................... 33-43
Test Suite Creation........................... 33-44
Test Selection............................... 33-44
Test Running ............................... 33-45
Programmatic Access of Test Diagnostics .......... 33-45
Test Runner Customization..................... 33-46Author Class-Based Unit Tests in MATLAB.......... 33-47
The Test Class Definition...................... 33-47
The Unit Tests.............................. 33-47
Additional Features for Advanced Test Classes...... 33-49Write Simple Test Case Using Classes.............. 33-51xxxv