How to export all the Test sequences as excel or any other format from Simulink Test manager?
Show older comments
How to export all the Test sequences as excel or any other format from Simulink Test manager?
Accepted Answer
More Answers (1)
Guilherme Costa Nascimento
on 29 Oct 2025
The code below gives a very simple way to do this. The more complex your Test Sequence and the more data you want to retain from it, the more you will need to add to this code.
I would advise against exporting to Excel because it's hard to represent the Test Sequence hierarchy using a tabular format. Instead, consider generating a report to share with others for review or documentation purposes.
% Path to the Test Sequence block
blkName = "myHarness/Test Sequence";
% List of steps for the Test Sequence
testSequenceSteps = sltest.testsequence.findStep(blkName);
% Preallocate table to store Test Sequence data
varNames = ["StepIndex", "StepName", "StepAction", "Transition", "Condition"];
testSequenceTable = array2table(strings(0, 5), "VariableNames", varNames);
% Go through each step
for i = 1:length(testSequenceSteps)
% Get step information
stepName = testSequenceSteps{i};
stepStruct = sltest.testsequence.readStep(blkName, stepName);
stepData = string({num2str(stepStruct.Index), stepStruct.Name, stepStruct.Action, '', ''});
% Table to store data for this step and its transitions
testStepTable = array2table(stepData, "VariableNames", varNames);
testStepTable = [testStepTable; array2table(strings(stepStruct.TransitionCount - 1, 5), ...
"VariableNames", varNames)];
% Get data for each transition for this step
for j = 1:stepStruct.TransitionCount
transitionStruct = sltest.testsequence.readTransition(blkName, stepName, j);
testStepTable{j, [4 5]} = string({transitionStruct.NextStep, transitionStruct.Condition});
end
% Add step data to main table
testSequenceTable = [testSequenceTable; testStepTable];
end
writetable(testSequenceTable, 'exportedTestSequence.xlsx');
Categories
Find more on Test Scripts in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!