function generate_unit_test_report(tests,output_filename)
% generate_unit_test_report - generate a text report of the unit test results.
%
% Inputs:
% tests - structure array containing test results
% output_filename - the name of the file to output report to
%
% Example:
% generate_unit_test_report(tests,'d:\docs\unit_test_report.txt')
%
% Other m-files required: none
%
% See also: unit_test, run_unit_test_batch, make_simulink_unit_test
% Author: Carl Kritzinger
% KAT DSP Team
% email address: carl@ska.ac.za
% November 2005
%------------- MAIN --------------
output_file = fopen(output_filename,'wt');
time = clock;
fprintf(output_file,'Unit test report generated at %d:%d on %d/%d/%d\n', time(4),time(5),time(3),time(2),time(1));
for kk = 1:length(tests)
test_report = generate_single_unit_test_report(tests(kk));
fprintf(output_file,'%s \n',test_report);
fprintf(output_file,'------------------------------------------------\n');
end
fclose(output_file);
function test_report = generate_single_unit_test_report(test)
if test.is_simulink == 1
if test.function_created_sub_system
comp_type = 'simulink scripted sub-system';
else
comp_type = 'simulink block';
end
else
comp_type = 'MATLAB function';
end
test_report = sprintf(...
'\n Test file : %s \n Component : %s (%s) \n Parameters : %s \n Results : \n',...
test.test_file_name,...
test.component,...
comp_type,...
cell2str(test.parameters));
for kk = 1:length(test.test_cases)
test_report = [test_report sprintf(' test case number %d : %s \n',kk,test_case_result_generator(test.test_cases(kk)))];
end
function s = cell2str(x)
s = '{';
for kk = 1:length(x)
s = [s '[' num2str(x{kk}) ']' ];
end
s = [s '}'];