matlab.unittest.plugins.TestRunProgressPluginclass
插件测试运行进展报告
描述
的TestRunProgressPlugin
类创建一个插件测试运行报告进展。
建设
matlab.unittest.plugins.TestRunProgressPlugin.withVerbosity (
构造一个v
)TestRunProgressPlugin
为指定的冗长。
matlab.unittest.plugins.TestRunProgressPlugin.withVerbosity (
将文本输出重定向到输出流。v
,流
)
输入参数
v
- - - - - -冗长的水平
0
|1
|2
|3
|4
|matlab.unittest.Verbosity
枚举|枚举名称字符串或字符向量
冗长的层面上,指定为一个整数值介于0到4matlab.unittest.Verbosity
枚举对象,或一个字符串标量特征向量对应一个预定义的枚举成员的名字。整数值对应的成员matlab.unittest.Verbosity
枚举。
数字表示法 | 枚举成员名 | 冗长的描述 |
---|---|---|
0 |
没有一个 |
任何信息 |
1 |
简洁 |
最小的信息 |
2 |
简洁的 |
适度的信息 |
3 |
详细的 |
一些补充信息 |
4 |
详细的 |
大量的补充信息 |
流
- - - - - -插件指导文本输出的位置
ToStandardOutput
实例(默认)|OutputStream
实例
位置插件指导文本输出,指定为一个OutputStream
实例。默认情况下,插件使用OutputStream
子类ToStandardOutput
流。
复制语义
句柄。学习如何处理类影响复制操作,明白了复制对象。
例子
创建插件测试运行进展
创建一个基于函数的测试cylinderPlotTest
在文件在您的工作目录中。
函数测试= cylinderPlotTest测试= functiontests (localfunctions);结束函数setupOnce testCase.TestData (testCase)。图=图;addTeardown (testCase @close testCase.TestData.Figure)结束函数设置(testCase) testCase.TestData。轴=轴(“父”,testCase.TestData.Figure);addTeardown (testCase @clf testCase.TestData.Figure)汽缸(testCase.TestData.Axes, 10)结束函数testXLim (testCase) xlim = testCase.TestData.Axes.XLim;verifyLessThanOrEqual (testCase xlim(1), -10年,“最低x-limit太大”)verifyGreaterThanOrEqual (testCase xlim(2), 10日“最大x-limit太小”)结束函数zdataTest (testCase) s = findobj (testCase.TestData.Axes,“类型”,“表面”);verifyEqual (testCase, min (s.ZData (:)), 0,“缸最小值是不正确的”)verifyEqual (testCase, max (s.ZData (:)), 1,“马克斯汽缸值是不正确的”)结束
在命令提示符处运行测试。
结果=运行(cylinderPlotTest);
运行cylinderPlotTest . .完成cylinderPlotTest __________
默认情况下,测试运行器使用冗长级别2。
创建一个测试运行器在一级报告诊断,并重新运行测试。
进口matlab.unittest.TestRunner进口matlab.unittest.plugins.TestRunProgressPlugin跑步者= TestRunner.withNoPlugins;p = TestRunProgressPlugin.withVerbosity (1);runner.addPlugin (p);结果= runner.run (cylinderPlotTest);
. .
创建一个测试运行器报告了4级诊断,并重新运行测试。
跑步者= TestRunner.withNoPlugins;p = TestRunProgressPlugin.withVerbosity (4);runner.addPlugin (p);结果= runner.run (cylinderPlotTest);
运行cylinderPlotTest设置cylinderPlotTest评估TestClassSetup: setupOnce运行在0.067649秒内完成设置cylinderPlotTest cylinderPlotTest / testXLim评估TestMethodSetup:设置评估测试:testXLim评估TestMethodTeardown:拆卸评价addTeardown功能:clf做cylinderPlotTest / testXLim在0.053834秒内运行cylinderPlotTest / zdataTest评估TestMethodSetup:设置评估测试:zdataTest评估TestMethodTeardown:拆卸评价addTeardown功能:clf cylinderPlotTest / zdataTest 0.037715秒完成拆除cylinderPlotTest评估TestClassTeardown: teardownOnce评估addTeardown功能:关闭完成拆除cylinderPlotTest在0.022783秒内完成cylinderPlotTest在0.18198秒内__________
配置的进展消息输出
创建一个类的名字ExampleProgressTest
在一个文件在你当前的工作目录。
classdefExampleProgressTest < matlab.unittest.TestCase方法(测试)函数testOne (testCase)%测试失败testCase.verifyEqual (5,4)结束函数testTwo (testCase)%测试通过testCase.verifyEqual (5,5)结束结束结束
在命令提示符下,创建测试套件和一个跑步者在冗长的3级,然后运行测试。
进口matlab.unittest.TestSuite进口matlab.unittest.TestRunner进口matlab.unittest.plugins.TestRunProgressPlugin套件= TestSuite.fromClass (? ExampleProgressTest);跑步者= TestRunner.withNoPlugins;p = TestRunProgressPlugin.withVerbosity (3);runner.addPlugin (p);结果= runner.run(套);
运行ExampleProgressTest设置ExampleProgressTest完成设置ExampleProgressTest 0秒运行ExampleProgressTest / testOne做ExampleProgressTest / testOne在0.0049988秒内运行ExampleProgressTest / testTwo ExampleProgressTest / testTwo 0.0044541秒完成拆除ExampleProgressTest完成拆除ExampleProgressTest在0秒在0.0094529秒内完成ExampleProgressTest __________
创建一个新的插件直接输出到一个文件命名myOutput.log
,并重新运行测试。
进口matlab.unittest.plugins.ToFile输出文件=“myOutput.log”;跑步者= TestRunner.withNoPlugins;p = TestRunProgressPlugin.withVerbosity(3,去整理(输出文件);runner.addPlugin (p);结果= runner.run(套);
观察插件创建的文件的内容。
disp (fileread(输出文件)
运行ExampleProgressTest设置ExampleProgressTest完成设置ExampleProgressTest 0秒运行ExampleProgressTest / testOne做ExampleProgressTest / testOne在0.0050172秒内运行ExampleProgressTest / testTwo ExampleProgressTest / testTwo 0.0049449秒完成拆除ExampleProgressTest完成拆除ExampleProgressTest在0秒在0.009962秒内完成ExampleProgressTest __________
版本历史
介绍了R2014b
MATLAB命令
你点击一个链接对应MATLAB命令:
运行该命令通过输入MATLAB命令窗口。Web浏览器不支持MATLAB命令。万博1manbetx
你也可以从下面的列表中选择一个网站:
表现最好的网站怎么走吗
选择中国网站(中文或英文)最佳站点的性能。其他MathWorks国家网站不优化的访问你的位置。