Customise test report generated by matlab.unittest.TestCase.generatePDFReport method
Show older comments
Hi,
I am using matlab.unitTest.TestCase.generatePDFReport method to generate my testReport. I see that the report contains the failure/pass or some diagnostics from the command window only. I want to add some piecharts or some messages to the report, is it possible?
Thanks in advance.
Accepted Answer
More Answers (1)
Mattia Marsetti
on 14 Mar 2024
0 votes
Hi Harish
You can use the FigureDiagnostic class to add a custom artifact that will print together with the test as in the following example, where I have defined a simple test class, with a unique test method which will always fail and report a figure as diagnostic.
Please note that instead of "fdiag" you can have a different diagnostic or a simple text that will be reported in the final pdf report. See documentation here: https://it.mathworks.com/...diagnostic
classdef myTestCase < matlab.unittest.TestCase
methods(Test)
function test_with_diag_figure(testCase)
f=figure;
spy;% plot your custom chart here
fdiag=FigureDiagnostic(f,'Formats',{'png'},'Prefix','LoggedFigure_');
testCase.log(1,fdiag);% if you want to always log the figure in the test, even if it passes
testCase.verifyLessThan(1,0,fdiag);% this will add the figure as a detailed diag in case of failure
end
end
end
Is it what you where looking for?
Categories
Find more on Construct and Work with Object Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!