How to export test manager results to a dataset programmatically?

24 ビュー (過去 30 日間)
William Curry
William Curry 2019 年 12 月 18 日
編集済み: Shishir Dwivedi 2020 年 1 月 22 日
I'm trying to export test manager results to a dataset object so I can later import it into the Simulink Data Inspector. When you use the sl.testmanager.exportResults function it only exports in the '.mldatx' format. You can manually export test manager results but only on individual result sets so it take a lot of time to export a large list of tests.

採用された回答

Shishir Dwivedi
Shishir Dwivedi 2019 年 12 月 27 日
Hello William,
You can perform following steps to achive the goal.
  1. Set data saving format as "Dataset" in "Data Import/Export" section of Model configuration parameters.
  2. In Simulink Test Manager, navigate to Custom Crieria section and assign the Iteration Results in the base workspace.
assignin('base', sltest_iterationName, sltest_simout);
This will create SimulationOutput variable(s) in the base workspace corresponding to Iteration names, once test execution is done you can extract Dataset values from SimulationOutput for further processing.
-Shishir.
  2 件のコメント
Joseph Krese
Joseph Krese 2020 年 1 月 21 日
Hi Shishir,
I attempted to use this command, but it wil not return the name of the test. When I run the test with that command in the custom criteria, I get an error that the sltest_iterationName variable is blank. Working with Bill, we tried several different things to return the current test case name, but have been unsuccessful so far. sltest_iterationName is listed in the comments of the custom criteria as being available, so I'm not sure why we can't get the test name? Can you provide any help with that?
Shishir Dwivedi
Shishir Dwivedi 2020 年 1 月 22 日
編集済み: Shishir Dwivedi 2020 年 1 月 22 日
Hello Joseph,
I understand that you want to get Test case name from the execution results. Can you please try following command(s) in custom criteria section and let me know if it answers your query.
assignin('base', 'TestCaseName', sltest_testCase.Name);
This command will create a variable in Base Workspace with name "TestCaseName", the value of this variable would store test case name as defined in Test manager.
Now, if you want the test case name to store test case object, you can use following commands.
tcName = matlab.lang.makeValidName(sltest_testCase.Name);
%Note: The test case name can contain spaces/special characters which might not be %valid variable name(s), hence creating a valid variable name here to assign in the %base workspace
assignin('base', tcName, sltest_testCase); %copy test case object to the test case variable.
In case you want to know test iterations name, please use following commands in custom criteria section.
testIterations = getIterations(sltest_testCase);
assignin('base', 'testIterations', {testIterations.Name});
Hope this helps !
Best Regards,
Shishir.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTest Scripts についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by