Main Content

Append Code to a Test Report

This example shows how to use a customization class to print integrated code in a test results report. If you test models that include handwritten code, you can print the code to a report to be reviewed with the test results.

The cruise control model integrates handwritten C code using an S-Function builder block. The C code is a utility function that disregards simultaneous pressing of two buttons: Accel/Res and Coast/Set.

This example requires Simulink® Report Generator™ and Microsoft® Windows.

Example Files

Before running this example, set the filenames.

rptCustom = 'textAppendReport.m';
resultsFile = 'DoublePressSfcnSimTestResults';
filePath = fullfile(tempdir,'textAppendedReport.zip');

Report Customization Class

The report customization class textAppendReport.m appends the S-Function code to the end of the report body.

open(rptCustom)

Load the Results and Create the Report

1. Load the test results file.

result = sltest.testmanager.importResults(resultsFile);

2. Create the test report using the customization.

sltest.testmanager.report(result,filePath,...
    'CustomReportClass','textAppendReport',...
    'IncludeTestResults',0)

3. The report appends the S-Function wrapper code:

For more information on report customization, see Customize Test Results Reports.

sltest.testmanager.clearResults;
sltest.testmanager.close;