Customise test report generated by matlab.unittest.TestCase.generatePDFReport method
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Mattia Marsetti
am 14 Mär. 2024
0 Stimmen
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?
Kategorien
Mehr zu Collect Decision, Condition, and MC/DC Coverage for MATLAB Code finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!