Main Content

Class-Based Unit Tests

Write class-based tests; parameterize tests; apply fixtures; select and run tests

Write xUnit-style tests to check that the output of MATLAB®code is as you expect. Class-based unit tests give you access to the full unit testing framework functionality. For example, you can write parameterized tests, tag your tests, or use shared test fixtures.

To get started, seeAuthor Class-Based Unit Tests in MATLABandWrite Simple Test Case Using Classes.

Functions

runtests Run set of tests
testsuite Create suite of tests
testrunner Create test runner
run (TestSuite) RunTestSuitearray usingTestRunnerobject configured for text output
run (TestRunner) Run all tests inTestSuitearray
run (TestCase) RunTestCasetest
runInParallel Run all tests inTestSuitearray in parallel

Classes

matlab.unittest.TestCase 超类的所有matlab.unittesttest classes
matlab.unittest.TestSuite Class for grouping tests to run
matlab.unittest.Test Specification of single test method
matlab.unittest.TestRunner Class for running tests inmatlab.unittestframework
matlab.unittest.TestResult Result of running test suite

Packages

matlab.unittest Summary of packages and classes inMATLABUnit Test Framework
matlab.unittest.qualifications Summary of classes inMATLABQualifications Interface
matlab.unittest.constraints Summary of classes inMATLABConstraints Interface
matlab.unittest.diagnostics Summary of classes inMATLABDiagnostics Interface
matlab.unittest.fixtures Summary of classes inMATLABFixtures Interface
matlab.unittest.parameters Summary of classes associated withMATLABUnit Test parameters
matlab.unittest.plugins Summary of classes inMATLABPlugins Interface
matlab.unittest.selectors Summary of classes inMATLABSelectors Interface
Simulink.sdi.constraints.MatchesSignal Constraint that compares time series data with tolerances using the Simulation Data Inspector

Topics

Write Tests

Write Parameterized Test

Run Tests and Analyze Results