The MATLAB® Unit Testing Frameworks provides test tool authors the ability to customize the testing environment. You can extend test writing through custom constraints, fixtures, and diagnostics, and extend test running and result reporting through custom plugins for the test runner.
matlab.unittest.constraints.Constraint |
Fundamental interface class for comparisons |
matlab.unittest.constraints.BooleanConstraint |
Interface class for boolean combinations of constraints |
matlab.unittest.constraints.Tolerance |
Abstract interface class for tolerances |
matlab.unittest.fixtures.Fixture |
Interface class for test fixtures |
matlab.unittest.diagnostics.Diagnostic |
Fundamental interface class for matlab.unittest diagnostics |
matlab.unittest.diagnostics.ConstraintDiagnostic |
Diagnostics specific to matlab.unittest constraints |
matlab.unittest.plugins.TestRunnerPlugin |
Plugin interface for extending TestRunner |
matlab.unittest.plugins.QualifyingPlugin |
Interface for plugins that perform system-wide qualifications |
matlab.unittest.plugins.OutputStream |
Interface that determines where to send text output |
matlab.unittest.plugins.plugindata |
Summary of classes in MATLAB Plugin Data Interface |
This example shows how to create a custom constraint that determines if a given value is the same size as an expected value.
Create Custom Boolean Constraint
This example shows how to create a custom boolean constraint that determines if a given value is the same size as an expected value.
This example shows how to create and apply a custom tolerance.
This example shows how to create a basic custom fixture.
Create Advanced Custom Fixture
This example shows how to create a custom fixture with a configurable constructor.
Write Plugins to Extend TestRunner
Use the TestRunnerPlugin
class
to extend the test runner. You can implement methods to extend the
creation, setup, run, and teardown of tests or test fixtures. The TestRunner
runs
these methods as shown in the figure.
This example shows how to create a custom plugin that counts the number of passing and failing assertions when running a specified test suite.
Write Plugin to Save Diagnostic Details
This example shows how to create a custom plugin to save diagnostic details. The plugin listens for test failures and saves diagnostic information so you can access it after the framework completes the tests.
Plugin to Generate Custom Test Output Format
This example shows how to create a plugin that uses a custom format to write finalized test results to an output stream.