Test delle unità basati su script
Scrivere test basati su script per verificare che gli output degli script, delle funzioni o delle classi di MATLAB® siano quelli previsti. Ad esempio, è possibile utilizzare la funzione assert
per verificare che i valori di output effettivi corrispondano a quelli previsti oppure per verificare che le variabili di output siano della dimensione e del tipo corretti. Per eseguire gli script di test, utilizzare la funzione runtests
.
Per iniziare, vedere Write Script-Based Unit Tests.
Per una scrittura maggiormente avanzata del test, che comprenda l'accesso a molti tipi diversi di qualifiche di test, considerate la scrittura Test delle unità basati su funzioni o Test delle unità basati su classi.
App
Test Browser | Run MATLAB tests and view results (Da R2023a) |
Classi
TestResult | Result of running test suite |
Argomenti
- Write Test Using Live Script
This example shows how to write a live script that tests a function that you create.
- Write Script-Based Unit Tests
Write a script to test 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.
- Run Tests Using Test Browser
Run your tests interactively by using the test browser. (Da R2023a)
- Analyze Test Case Results
This example shows how to analyze the information returned by a test runner.
- Analyze Failed Test Results
This example shows how to identify and handle failed tests.
- Rerun Failed Tests
Rerun failed tests quickly and conveniently.
- Extend Script-Based Tests
Access additional functionality using script-based tests, including test selection, programmatic access of test diagnostics, and test runner customization.
- Ways to Write Unit Tests
Choose a test authoring scheme that best suits your requirements and your preferred workflow.