Ausführen von Unit-Tests
Sie können Tests auswählen und ausführen, den Testlauf anpassen und Test- und Abdeckungsergebnisse analysieren
Sie können Ihre Tests interaktiv im MATLAB® Editor oder Live Editor oder in der Test Browser App ausführen, oder Tests programmatisch ausführen, beispielsweise mit der Funktion runtests oder der Methode run der matlab.unittest.TestSuite-Klasse. Sie können Ihren Testlauf mit Optionen wie der Parallelausführung von Tests (Parallel Computing Toolbox™ erforderlich) oder einem bestimmten Testausgabe-Detailgrad anpassen. Sie können Code-Abdeckungsmetriken erfassen, wenn Sie Tests ausführen und die Test- und Abdeckungsergebnisse analysieren.
Apps
| Test Browser | Run MATLAB tests and view results (Seit R2023a) |
Funktionen
runtests | Run set of tests |
testsuite | Create suite of tests |
testrunner | Create test runner (Seit R2021a) |
run (TestSuite) | Run test suite using default test runner |
run (TestRunner) | Run test suite |
run (TestCase) | Run tests corresponding to test case |
runInParallel | Run all tests in test suite in parallel |
Klassen
matlab.unittest.TestCase | Superclass of all test classes |
matlab.unittest.TestSuite | Fundamental interface for grouping tests to run |
matlab.unittest.Test | Specification of a single test |
matlab.unittest.TestRunner | Class for running tests in unit testing framework |
matlab.unittest.TestResult | Result of running test suite |
matlab.coverage.Result | Result of code coverage analysis (Seit R2023a) |
Namespaces
matlab.unittest | Summary of classes and namespaces in MATLAB unit testing framework |
matlab.unittest.plugins | Summary of classes in MATLAB plugins interface |
matlab.unittest.selectors | Summary of classes in MATLAB selectors interface |
Themen
Ausführen von Tests
- Create Simple Test Suites
Combine tests into test suites, whether they are organized in namespaces and classes or files and folders, or both. - Run Tests for Various Workflows
Explore different ways to run tests. - Run Tests Using Test Browser
Run your tests interactively by using the test browser. (Seit R2023a) - Run Tests in Editor
Run your tests while working in the Editor or Live Editor. - Add Plugin to Test Runner
Add a plugin to the test runner. - Compile MATLAB Unit Tests
Create a standalone application to run your tests on target machines that do not have MATLAB installed.
Analysieren der Ergebnisse
- Analyze Test Case Results
Analyze the information that a test runner returns. - Analyze Failed Test Results
Identify and handle failed tests. - Rerun Failed Tests
Rerun failed tests quickly and conveniently. - Dynamically Filtered Tests
Assumption failures produce filtered tests that are marked asIncompleteinstead of producing test failures. Monitor the filtered tests for test code that the testing framework does not execute. - Programmatically Access Test Diagnostics
Programmatically access the diagnostics that the testing framework records on test results. - Types of Code Coverage for MATLAB Source Code
Use different types of code coverage to analyze your MATLAB source code. - Collect Statement and Function Coverage Metrics for MATLAB Source Code
Collect and analyze information about statement and function coverage for your MATLAB source code.