Exécuter des tests unitaires
Sélectionner et exécuter des tests, personnaliser l’exécuteur de tests et analyser les résultats des tests et de la couverture
Exécutez vos tests de manière interactive dans MATLAB® Editor, le Live Editor ou l’application Test Browser ou bien de manière programmatique, par exemple avec la fonction runtests
ou la méthode run
de la classe matlab.unittest.TestSuite
. Personnalisez l’exécution de vos tests avec des options, par exemple en les exécutant en parallèle (nécessite Parallel Computing Toolbox™) ou en spécifiant le niveau de détail de la sortie du test. Collectez des mesures de couverture du code pendant l’exécution de vos tests et analysez les résultats des tests et de la couverture.
Applications
Test Browser | Run MATLAB tests and view results (depuis R2023a) |
Fonctions
runtests | Run set of tests |
testsuite | Create suite of tests |
testrunner | Create test runner (depuis 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 |
Classes
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 (depuis 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 |
Rubriques
Exécuter des 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. (depuis 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.
Analyser les résultats
- 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 asIncomplete
instead 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.