MATLAB Examples

Append Code to a Test Report

This example shows how to use a customization class to include code in your test report. When testing systems that include handwritten code, reviewing the code itself can be part of reviewing the test results. Including the code in the test report allows you use a single document.

The example model includes handwritten C code using an S-Function builder block. The block is a component of a cruise control system; functionally, it disregards simultaneous pressing of the Accel/Res switch and the Coast/Set switch.

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

Contents

Navigate to the Example Folder

Before running this example, navigate to the example folder and set the filenames.

cd(fullfile(matlabroot,'examples','simulinktest'))
className = 'textAppendReport';
resultsFile = 'DoublePressSfcnSimTestResults';
filePath = 'textAppendedReport.zip';

Report Customization Class

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

open(className)

Load the Test Results and Create the Test 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',className,...
	'IncludeTestResults',0)

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

For more information on report customization, see Customize Generated Reports

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