Main Content

本页采用了机器翻译。点击此处可查看英文原文。

sltest.testmanager.TestResultReport 类

命名空间: sltest.testmanager

定制生成的结果报告

描述

sltest.testmanager.TestResultReport 是一个使您能够自定义测试管理器的结果报告生成的类。您可以派生类并覆盖各种方法来定制您的报告。通过自定义方法,您可以更改报告标题、图表、表格、标题、图标等。

有关自定义报告的更多信息和示例,请参阅 自定义测试结果报告

sltest.testmanager.TestResultReport 类是 handle 类。

类属性

HandleCompatible
true

有关类属性的信息,请参阅 类属性

创建对象

Obj = sltest.testmanager.TestResultReport(resultObjects,reportFilePath) 创建报告生成对象。

要使用此类,您必须从该类继承。使用以下代码作为类定义代码的第一行来从该类继承。

% class definition
classdef CustomReport < sltest.testmanager.TestResultReport
    %
    % Report customization code here
    %
end

输入参量

全部展开

从结果集对象获取结果,指定为 sltest.testmanager.ResultSet 对象。

生成的报告的文件名和路径。文件路径必须具有 pdf、docx 或 zip 文件扩展名,这些是唯一支持的文件类型。

示例: 'C:\MATLAB\Report.pdf'

属性

全部展开

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

正文段落文本字体颜色,指定为字符向量。

示例: 'Red'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

正文段落文本字体样式名称,指定为字符向量。

示例: 'Times New Roman'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

正文段落文本字体大小,以点为单位指定为字符向量。

示例: '14pt'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

第一级部分缩进宽度,以毫米为单位指定为字符向量。

示例: '5mm'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

第二级部分缩进宽度,以毫米为单位指定为字符向量。

示例: '8mm'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

第三级部分缩进宽度,以毫米为单位指定为字符向量。

示例: '10mm'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

用于报告定制的 Microsoft® Word 模板文件的文件名和路径,指定为字符向量。有关使用模板文件的更多信息,请参阅 使用模板生成报告。仅当您拥有 MATLAB® Report Generator™ 许可证时,此参量的使用才有效。

示例: 'C:\MATLAB\CustomReportTemplate.dotx'

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

章节标题文本字体颜色,指定为字符向量。

示例: 'Blue'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

章节标题文本字体样式名称,指定为字符向量。

示例: 'Times New Roman'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

章节标题文本字体颜色,以点为单位指定为字符向量。

示例: '16pt'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

禁用测试结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\disabled_test_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

失败测试结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\failed_test_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

不完整测试结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\incomplete_test_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

未对齐测试结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\misaligned_test_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

已通过的测试结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\passed_test_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

测试用例结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\test_case_result_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

测试文件结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\test_file_result_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

迭代结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\iteration_result_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

测试套件结果的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\test_suite_result_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

覆盖率报告中模型引用的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\model_reference_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

覆盖率报告中顶层模型的图标图像的文件名和路径,指定为字符向量。指定的图标文件替换了默认的图标图像。图标图像缩小到 16x16 像素。

示例: 'C:\MATLAB\top_level_model_icon.png'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

在报告中包含信号比较图,指定为 truefalse

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

在报告中包含覆盖率结果,指定为 truefalse

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

在报告中包含错误消息,指定为 truefalse

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

包括用于在报告中运行测试的 MATLAB 版本,指定为 truefalse

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

在报告中包含仿真元数据,指定为 truefalse。元数据包括 Simulink® 模型、模型版本、模型路径、仿真模式、覆盖 SIL 或 PIL 模式、配置集、变体配置、求解器名称和类型、最大步长、开始和停止时间、校验和、用户 ID、机器名称、平台以及 Simulink 版本和发布版。

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

在报告中包含仿真信号输出图,指定为 truefalse

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

在报告中包含与测试文件、测试套件或测试用例相关的测试需求,指定为 truefalse

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

在报告中包括全部或部分测试结果。您可以选择所有通过和失败的结果(指定为值 0),仅选择通过的结果(指定为值 1),或者仅选择失败的结果(指定为值 2)。

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

报告生成完成后打开报告,指定为布尔值 true 或不打开报告 false

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

报告标题,指定为字符向量

示例: 'Test Case Report'

属性:

SetAccess
public
GetAccess
public
Dependent
true
NonCopyable
true

各部分之间的间距,以毫米为单位指定为字符向量。

示例: '5mm'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

绘图高度,以像素为单位指定为字符向量。

示例: '500px'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

绘图宽度,以像素为单位指定为字符向量。

示例: '400px'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

表格字体颜色,指定为字符向量。

示例: 'Blue'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

表字体样式名称,指定为字符向量。

示例: 'Times New Roman'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

表格字体大小,以点为单位指定为字符向量。

示例: '10pt'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

标题字体颜色,指定为字符向量。

示例: 'Blue'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

标题字体样式名称,指定为字符向量。

示例: 'Times New Roman'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

标题字体大小,以点为单位指定为字符向量。

示例: '20pt'

属性:

SetAccess
protected
GetAccess
public
Dependent
true
NonCopyable
true

方法

全部展开

示例

全部折叠

% class definition
classdef CustomReport < sltest.testmanager.TestResultReport
    % This custom class used by Test Manager 
    % adds a custom message in the title page

    % Class constructor
    methods
        function this = CustomReport(resultObjects, reportFilePath)
            this@sltest.testmanager.TestResultReport...
               (resultObjects,reportFilePath);
        end
    end

    methods(Access=protected)
        function addTitlePage(obj)
            import mlreportgen.dom.*;

            % Call the superclass method to get the default behavior
            addTitlePage@sltest.testmanager.TestResultReport(obj);

            % Add a custom message
            label = Text('Some custom content can be added here');
            append(obj.TitlePart,label);
        end
    end
end
% import existing results or use sltest.testmanager.run to run tests
% and collect results
result = sltest.testmanager.importResults('testResults.mldatx');
filePath = 'testreport.zip';
sltest.testmanager.report(result,filePath,...
			'Author','User',...
			'Title','Test',...
			'IncludeMLVersion',true,...
			'IncludeTestResults',int32(0),...
			'CustomReportClass','CustomReport',...
			'LaunchReport',true);

版本历史记录

在 R2016a 中推出