How to export all the Test sequences as excel or any other format from Simulink Test manager?
35 ビュー (過去 30 日間)
古いコメントを表示
Divyabharathi Varadharajan
2023 年 6 月 9 日
回答済み: Guilherme Costa Nascimento
2025 年 10 月 29 日 19:41
How to export all the Test sequences as excel or any other format from Simulink Test manager?
0 件のコメント
採用された回答
atharva
2023 年 11 月 14 日
Hey Divyabharathi,
I understand that you want to export the test sequences.
Currently there isn't an automated way to export the Test Sequence information to TXT/XML files.
As a workaround, you can use some of the Test Sequence APIs to get the step and transition information. Here are some resources you can utilize to accomplish this:
1. To get names/paths of all the steps in a Test Sequence block: sltest.testsequence.findStep(blockPath)
2. Then you can loop over all the step paths to read step information for each step.
3. To get the information for each step as a struct: sltest.testsequence.readStep(blockPath, stepPath)
(The number of transitions is in the return struct)
4. For Each step, you can loop over all the transitions to read transition information for each step.
5. To get the information for each transition as a struct: sltest.testsequence.readTransition(blockPath, stepPath, transitionIndex)
After getting all the information, the you can write them into TXT or XML files.
6. Please take a look at the example in the attachment. The script "programaticallySaveTestSequenceToXML.m" works to export test sequences as an "xml" file. This script is modified from the shipped example below.
- Programmatically Create a Test Sequence
I hope this helps!
3 件のコメント
Fernando Junior
2024 年 3 月 1 日
Yes. I would like to know how to find this .m custom file that you generated. Is it in guthub?
Anila
2025 年 2 月 23 日
Hi Atharva, where can I find the file 'programaticallySaveTestSequenceToXML.m' ? Awaiting your response.
その他の回答 (1 件)
Guilherme Costa Nascimento
2025 年 10 月 29 日 19:41
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');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Test Scripts についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!