How to export test manager results to a dataset programmatically?

32 views (last 30 days)
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.

Accepted Answer

Shishir Dwivedi
Shishir Dwivedi on 27 Dec 2019
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 Comments
Joseph Krese
Joseph Krese on 21 Jan 2020
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 on 22 Jan 2020
Edited: Shishir Dwivedi on 22 Jan 2020
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.

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!