Borrar filtros
Borrar filtros

In simulink testing how to generate a customize report which contain -> Test case is pass and fail and with their waveform of that test cases ?

4 visualizaciones (últimos 30 días)
I have perform simulink test after which the report is generated so, there is any way to generate customize test report in which we can include waveforms for that test cases or how can we include the waveforms generated in data inspector

Respuestas (1)

Sameer
Sameer el 23 de Mayo de 2024
Hi Saurabh
To generate a customized report in Simulink Test that includes the status of test cases (pass or fail) along with their corresponding waveforms, a process that combines Simulink Test with MATLAB scripting for report generation can be followed. This involves using the "Simulink Test” API to access test results and the "MATLAB Report Generator" to create the customized report.
  1. Run the Simulink Test Suite: First, the test suite is run using the "Simulink Test Manager", ensuring that tests are configured to log the necessary signals for inclusion in the report.
  2. Export Test Results Programmatically: After the tests have been run, the test results can be exported using the "Simulink Test” API. The "sltest.testmanager.run” function, can be used to run tests and obtain a result set object.
  3. Access Logged Data: For each test case result, the logged data needs to be accessed. This data could be logged in the "Simulation Data Inspector", requiring the use of the Data Inspector API to extract this data.
  4. Create a Report Using MATLAB Report Generator: The "MATLAB Report Generator" is used to programmatically create a report, adding sections for each test case indicating whether it passed or failed, and including plots of the relevant waveforms.
import mlreportgen.report.*
rpt = Report('TestReport','pdf');
%Iterate Through Test Results: For each test result, sections are added to the report. Conditional statements check if the test passed or failed.
for idx = 1:numel(resultObj)
testResult = resultObj.getTestResultByIndex(idx);
if strcmp(testResult.Outcome, 'Passed')
% Section for passed test
sec = Section;
sec.Title = ['Test Case Passed: ', testResult.Name];
add(rpt, sec);
else
% Section for failed test
sec = Section;
sec.Title = ['Test Case Failed: ', testResult.Name];
add(rpt, sec);
end
% Insert waveform plots here
% Extraction of waveform data from the Data Inspector
% Example of adding a figure:
fig = figure;
plot(dataFromTest); % Replace 'dataFromTest' with the actual data variable
img = Image(getSnapshotImage(fig, rpt));
add(sec, img);
close(fig);
end
close(rpt);
rptview(rpt);
Please refer to the below links for more information:
I hope this helps!
Sameer

Categorías

Más información sobre Results, Reporting, and Test File Management en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by