matlab.unittest.plugins.TestReportPluginclass
包:matlab.unittest.plugins
插件生成一个测试结果报告
描述
TestReportPlugin
创建一个插件,指导TestRunner
生产测试结果报告。使用这个插件,您可以生成可读和archivable测试报告。
建设
实例化一个TestReportPlugin
使用一个静态方法:
产生一个
。docx
报告中,使用producingDOCX
静态方法。产生一个
. html
报告中,使用producingHTML
静态方法。产生一个
PDF
报告中,使用producingPDF
静态方法。
属性
IncludeCommandWindowText
- - - - - -如果从命令窗口包含文本输出指标
假
(默认)|真正的
这个属性是只读的。
从命令窗口包含指标如果文本输出,指定为假
或真正的
(逻辑
0或1)。默认情况下,IncludeCommandWindowText
是假
从命令窗口和文本输出是排除在报告。报告中包括命令窗口文本,指定IncludeCommandWindowText
作为真正的
在插件结构。
IncludePassingDiagnostics
- - - - - -如果诊断指标包括传递事件
假
(默认)|真正的
这个属性是只读的。
如果诊断指标包括传递事件,指定为假
或真正的
(逻辑
0或1)。默认情况下,IncludePassingDiagnostics
是假
和诊断通过事件被排除在输出。包括诊断输出,通过事件指定IncludePassingDiagnostics
作为真正的
在插件结构。
LoggingLevel
- - - - - -最大冗长水平记录诊断包括插件
matlab.automation.Verbosity.Terse
(默认)|matlab.automation.Verbosity
枚举对象
这个属性是只读的。
最大冗长水平记录诊断包括插件,作为一个返回matlab.automation.Verbosity
枚举对象。记录在这个级别的插件包括诊断和下面。默认情况下,这个属性值matlab.automation.Verbosity.Terse
。您可以指定一个不同的插件施工期间日志级别。
记录诊断是诊断,您提供的测试框架调用日志(TestCase)
或日志(夹具)
方法。
方法
producingDOCX | 构建插件生产。docx 报告 |
producingHTML | 构建插件生产. html 报告 |
producingPDF | 构建插件生产. pdf 报告 |
复制语义
句柄。学习如何处理类影响复制操作,明白了复制对象。
例子
生成测试结果报告。docx
格式
从两个测试文件创建一个测试套件,套件,并生成一个。docx
报告的结果。
你的工作文件夹中创建一个新文件命名ScriptBasedTest.m
包含下面的测试脚本。脚本包含两个失败和不完整的测试。
% %测试两类expSolution =“双”;actSolution = 1;断言(isa (actSolution, expSolution))% %测试单个类expSolution =“单一”;actSolution = (“单一”);断言(isa (actSolution, expSolution))% %测试uint16类expSolution =“uint16”;actSolution = (“uint16”);断言(isa (actSolution, expSolution))% %测试失败断言(错误= = true);% %另一个失败的测试断言(strcmp (“相关”,“因果关系”))
创建一个文件命名ClassBasedTest.m
包含下面的测试类。
classdefClassBasedTest < matlab.unittest.TestCase属性(ClassSetupParameter)发电机= {“旋风”,“combRecursive”,“multFibonacci”};结束属性(MethodSetupParameter)种子= {0123,4294967295};结束属性(TestParameter) dim1 =结构(“小”,1“媒介”2,“大”3);dim2 =结构(“小”2,“媒介”3,“大”4);dim3 =结构(“小”3,“媒介”4“大”5);类型= {“单一”,“双”};结束方法(TestClassSetup)函数ClassSetup (testCase,发电机)源自=提高;testCase.addTeardown (@rng源自)rng(0,发电机)结束结束方法(TestMethodSetup)函数MethodSetup (testCase,种子)源自=提高;testCase.addTeardown (@rng源自)rng(种子)结束结束方法(测试,ParameterCombination =“顺序”)函数testSize (testCase, dim1 dim2 dim3) testCase.verifySize(兰德(dim1, dim2 dim3) [dim1 dim2 dim3])结束结束方法(测试,ParameterCombination =“成对”)函数testRepeatable (testCase, dim1 dim2 dim3)状态=提高;firstRun =兰德(dim1 dim2 dim3);rng(州)secondRun =兰特(dim1、dim2 dim3);testCase.verifyEqual (firstRun secondRun);结束结束方法(测试)函数testClass (testCase dim1、dim2类型)testCase.verifyClass(兰德(dim1、dim2类型),类型)结束结束结束
在命令提示符下,创建一个测试套件的测试文件。
进口matlab.unittest.TestRunner;进口matlab.unittest.TestSuite;进口matlab.unittest.plugins.TestReportPlugin;套件= testsuite ({“ScriptBasedTest”,“ClassBasedTest”})
套件= 1×284测试数组属性:名称ProcedureName TestClass BaseFolder参数化SharedTestFixtures标签测试包括:17独特的参数化,0共享测试夹具类,标签。
创建一个沉默的测试运行器,所以没有信息输出到命令窗口。创建一个TestReportPlugin
发送输出到文件MyTestReport.docx
。
跑步者= TestRunner.withNoPlugins;docxFile =“MyTestReport.docx”;插件= TestReportPlugin.producingDOCX (docxFile);
添加的插件TestRunner
并运行套件。
runner.addPlugin(插件);结果= runner.run(套房)
生成报告。请稍等。准备报告的内容。将内容添加到报告。写报告文件。报告被保存到:C: \ \ MyTestReport工作。多克斯结果= 1×284 TestResult数组属性:名称传递失败的不完整的时间细节总数:282年过去了,失败了,2不完整,测试时间0.73477秒。
打开测试报告。
打开(docxFile)
生成. pdf
报告,包括通过诊断
从基于函数的测试创建一个测试套件,套件,并生成报告的结果。包括通过诊断和文本输出到命令窗口。
你的工作文件夹中创建一个新文件命名FunctionBasedTest.m
基于函数包含以下测试。测试文件包括两个测试失败。
% %主要功能来生成测试函数测试= FunctionBasedTest测试= functiontests (localfunctions);结束% %测试函数函数passingTest (testCase) actSolution = 13 * 3 + 7 * 5;expSolution = 74;verifyEqual (testCase actSolution expSolution)结束函数failingTest (testCase) actSolution =单(1);verifyTrue (testCase actSolution)结束函数anotherPassingTest (testCase) verifyClass (testCase,字符串(“一些文本”),“字符串”)结束函数anotherFailingTest (testCase) verifyTrue (testCase, strcmp (“42”,“一切”))结束
在命令提示符下,创建一个测试套件FunctionBasedTest.m
。创建一个测试运行器显示输出到命令窗口使用默认插件。
进口matlab.unittest.TestRunner;进口matlab.unittest.TestSuite;进口matlab.unittest.plugins.TestReportPlugin;套件= testsuite (“FunctionBasedTest”);跑步者= TestRunner.withTextOutput;
创建一个TestReportPlugin
发送输出到文件MyTestReport2.pdf
。包括通过诊断和文本输出在报告中从命令窗口。
pdfFile =“MyTestReport2.pdf”;插件= TestReportPlugin.producingPDF (pdfFile,…“IncludingPassingDiagnostics”,真的,“IncludingCommandWindowText”,真正的);
添加的插件TestRunner
并运行套件。
runner.addPlugin(插件);结果= runner.run(套);
FunctionBasedTest运行。= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = FunctionBasedTest / failingTest验证失败。- - - - - - - - - - - - - - - - - - - - - - - -框架诊断:- - - - - - - - - - - - - - - - - - - - - - - - verifyTrue失败了。- - >的值必须是合乎逻辑的。它的类型是“单身”。实际单:1 - - - - - - - - - - - - - - - - - -堆栈信息:- - - - - - - - - - - - - - - - - -在C: \ \ FunctionBasedTest工作。在15米(failingTest) = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = . .= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = FunctionBasedTest / anotherFailingTest验证失败。- - - - - - - - - - - - - - - - - - - - - - - -框架诊断:- - - - - - - - - - - - - - - - - - - - - - - - verifyTrue失败了。- - >必须评估“真正”的价值。 Actual logical: 0 ------------------ Stack Information: ------------------ In C:\Work\FunctionBasedTest.m (anotherFailingTest) at 23 ================================================================================ . Done FunctionBasedTest __________ Failure Summary: Name Failed Incomplete Reason(s) =================================================================================== FunctionBasedTest/failingTest X Failed by verification. ----------------------------------------------------------------------------------- FunctionBasedTest/anotherFailingTest X Failed by verification. Generating report. Please wait. Preparing content for the report. Adding content to the report. Writing report to file. Report has been saved to: C:\Work\MyTestReport2.pdf
打开测试报告。
打开(pdfFile)
创建测试报告,包括工件
在一个文件在你当前的工作目录中,创建FigurePropTest
测试类。如果failingTest
测试方法失败(它总是在这个例子中),它使用一个FigureDiagnostic
保存图以后你可以检查它。
classdefFigurePropTest < matlab.unittest.TestCase属性TestFigure结束方法(TestMethodSetup)函数createFigure testCase (testCase)。TestFigure =图;结束结束方法(TestMethodTeardown)函数closeFigure (testCase)关闭(testCase.TestFigure)结束结束方法(测试)函数defaultCurrentPoint (testCase) cp = testCase.TestFigure.CurrentPoint;testCase。verifyEqual (cp [0 0),…默认当前点是不正确的)结束函数defaultCurrentObject (testCase)导入matlab.unittest.constraints.IsEmpty有限公司= testCase.TestFigure.CurrentObject;testCase.verifyThat (co、IsEmpty…默认当前对象应该是空的)结束函数failingTest (testCase)导入matlab.unittest.diagnostics.FigureDiagnostic无花果= testCase.TestFigure;ax =轴(图);冲浪(ax,山峰)testCase.verifyEmpty (testCase.TestFigure.Children,…FigureDiagnostic (testCase.TestFigure))结束结束结束
在命令提示符处,创建一个测试套件。
套件= testsuite (“FigurePropTest”);
创建一个记录诊断和沉默的测试运行器生成PDF格式的报告。
进口matlab.unittest.plugins.DiagnosticsRecordingPlugin进口matlab.unittest.plugins.TestReportPlugin跑步者= matlab.unittest.TestRunner.withNoPlugins;runner.addPlugin DiagnosticsRecordingPlugin runner.addPlugin (TestReportPlugin.producingPDF (“MyTestReport.pdf”))
更改默认工件根你当前的工作目录。
跑步者。ArtifactsRootFolder = pwd;
运行测试。第三个测试失败。
结果= runner.run(套房)
生成测试报告。请稍等。准备测试报告的内容。将内容添加到测试报告。编写测试报告文件。测试报告已经保存到:C: \锅\ MyTestReport。pdf结果= 1×3 TestResult数组属性:名称传递失败的不完整的时间细节总数:2通过,1失败(运行),0不完整,测试时间8.3355秒。
显示第三测试测试诊断结果。测试框架保存两个工件相关第三测试。默认情况下,FigureDiagnostic
数字对象保存为PNG文件和图文件。
(3).Details.DiagnosticRecord.TestDiagnosticResults结果
ans = DiagnosticResult属性:构件:[1×2 matlab.automation.diagnostics。FileArtifact] DiagnosticText:“图保存到:↵- - > C: \ \ 530 aa31c - 86 - c7 - 4712 - a064 d9f00ce041fb \ figure_dfd8c611 - 8387 - 4579 - 804 f - 6384642 ba4ff。无花果↵- - > C: \ \ 530 aa31c - 86 - c7 - 4712 - a064 d9f00ce041fb \ figure_dfd8c611 - 8387 - 4579 - 804 - f - 6384642 - ba4ff.png”
显示第一个工件的存储位置。
(3)结果.Details.DiagnosticRecord.TestDiagnosticResults.Artifacts (1)
ans = FileArtifact属性:名称:“figure_dfd8c611 - 8387 - 4579 - 804 f - 6384642 ba4ff。图”的位置:“C: \ \ 530 aa31c - 86 - c7 - 4712 - a064 d9f00ce041fb FullPath: " C: \ \ 530 aa31c - 86 - c7 - 4712 - a064 d9f00ce041fb \ figure_dfd8c611 - 8387 - 4579 - 804 - f - 6384642 - ba4ff.fig”
检查失败的测试相关的图片,打开文件中所示的位置FullPath
字段。另外,既然你生成PDF格式的测试报告,捕获的图像MyTestReport.pdf
。测试报告还包含了工件的路径。
版本历史
介绍了R2016bR2020a:生成测试报告(包括测试标签
测试报告生成的使用TestReportPlugin
类显示标记测试套件的测试标签元素。您可以生成标记测试报告在多克斯,HTML和PDF格式。
第一de MATLAB
Ha事实clic en联合国围绕此时一个埃斯特第一de MATLAB:
Ejecute el第一introduciendolo en la ventana de第一de MATLAB。洛杉矶navegadores网络没有admiten第一de MATLAB。
你也可以从下面的列表中选择一个网站:
表现最好的网站怎么走吗
选择中国网站(中文或英文)最佳站点的性能。其他MathWorks国家网站不优化的访问你的位置。