Skript-basierte Unit-Tests
Prüfen Sie mithilfe von Skript-basierten Tests, ob die Ausgaben von MATLAB®-Skripten, -Funktionen oder -Klassen wie erwartet ausfallen. Sie können beispielsweise mit der Funktion assert
testen, ob die tatsächliche Ausgabe dem erwarteten Wert entspricht, oder Sie können testen, ob die Ausgabe-Variablen dieselbe Größe und denselben Typ aufweisen. Verwenden Sie zur Ausführung Ihrer Test-Skripte die Funktion runtests
.
Informationen zum Einstieg finden Sie unter Write Script-Based Unit Tests.
Für das Verfassen komplexerer Tests sowie für den Zugriff auf verschiedene Arten von Testqualifizierungen sollten Sie Funktionsbasierte Unit-Tests oder Klassenbasierte Unit-Tests in Betracht ziehen.
Apps
Test Browser | Run MATLAB tests and view results (Seit R2023a) |
Funktionen
Klassen
TestResult | Result of running test suite |
Themen
- 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. (Seit 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.