Esecuzione di test unitari
Selezionare ed eseguire i test; personalizzare il test runner; analizzare i risultati del test e del coverage
Eseguire i test in modo interattivo nell'Editor di MATLAB® o nel Live Editor, oppure nell'app Test Browser o, in alternativa, eseguire i test in modo programmatico, ad esempio con la funzione runtests o il metodo run della classe matlab.unittest.TestSuite. Personalizzare l'esecuzione dei test con opzioni, quali l'esecuzione dei test in parallelo (richiede Parallel Computing Toolbox™) o la specifica di un livello di dettaglio dell'output dei test. Raccogliere le metriche di coverage del codice durante l'esecuzione dei test e analizzare i risultati dei test e del coverage.
App
| Test Browser | Run MATLAB tests and view results (Da R2023a) |
Funzioni
runtests | Run set of tests |
testsuite | Create suite of tests |
testrunner | Create test runner (Da 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 |
Classi
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 (Da 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 |
Argomenti
Esecuzione di test
- 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. (Da 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.
Analisi dei risultati
- 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.