扩展单元测试框架
Customize testing environment; author constraints, diagnostics, fixtures, and plugins
The MATLAB®unit testing framework provides test tool authors the ability to customize the testing environment. You can extend test writing through custom constraints, diagnostics, and fixtures, and extend test running and result reporting through custom plugins for the test runner.
Classes
Packages
matlab.untest.constraints Package |
Summary of classes inMATLAB约束Interface |
matlab.untest.diagnostics Package |
Summary of classes inMATLAB诊断接口 |
matlab.untest.fixtures Package |
Summary of classes inMATLABFixtures Interface |
matlab.untest.plugins Package |
Summary of classes inMATLAB插件接口 |
Topics
约束
- Create Custom Constraint
Create a custom constraint to determine if a given value has the same size as an expected value. - Create Custom Boolean Constraint
Create a custom Boolean constraint to determine if a given value has the same size as an expected value. - 创建自定义公差
此示例显示了如何创建和应用自定义公差。
Fixtures
- Create Basic Custom Fixture
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.
Plugins
- Write Plugins to Extend TestRunner
Use theTestRunnerPlugin
class to extend theTestRunner
. You can implement methods to extend the creation, setup, running, and teardown of tests or test fixtures. - 创建自定义插件
Create a custom plugin that counts the number of passing and failing assertions. - Run Tests in Parallel with Custom Plugin
Create a custom plugin that counts the number of passing and failing assertions when tests run in parallel. - 编写插件以添加数据以测试结果
Create a plugin that adds the actual and expected values in an assertion to theTestResult
目的。 - 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.