How to convert an array of sltest.tes​tmanager.T​estCase to sltest.tes​tmanger.Te​stSuite?

2 次查看(过去 30 天)
ts = array of sltest.testmanager.TestCase
run(ts)
Error:
Index exceeds the number of array elements (9).
Error in stm.internal.apiDetail.runWrapper
Error in sltest.testmanager.Test.run (line 30)
resultObj = stm.internal.apiDetail.runWrapper('idMap',idMap, ...
Error in sltest.testmanager.TestCase/run (line 6)
resultObj = sltest.testmanager.Test.run(obj, 0, varargin{:});
To make this run as TestSuite, I need to convert ts(sltest.testmanager.TestCase) to ts1(sltest.testmanager.TestSuite).

回答(1 个)

Aishwarya Shukla
Aishwarya Shukla 2023-3-29
To convert an array of sltest.testmanager.TestCase objects to a sltest.testmanager.TestSuite, you can use the sltest.testmanager.TestSuite.fromArray method. Here's an example:
% Create an array of sltest.testmanager.TestCase objects
tc1 = sltest.testmanager.TestCase('myTest1');
tc2 = sltest.testmanager.TestCase('myTest2');
ts = [tc1, tc2];
% Convert the array to a sltest.testmanager.TestSuite
ts1 = sltest.testmanager.TestSuite.fromArray(ts);
% Run the TestSuite
resultObj = run(ts1);
In this example, we create an array of two sltest.testmanager.TestCase objects (tc1 and tc2) and then convert it to a sltest.testmanager.TestSuite using the sltest.testmanager.TestSuite.fromArray method. We then run the resulting ts1 object using the run function.
  2 个评论
Montina
Montina 2023-4-4
Thanks @Aishwarya Shukla. I tried with this. But it is not working. Everytime it throws the error: The class sltest.testmanager.TestSuite has no Constant property or Static method named 'fromArray'. Checked for documentation too.
Aishwarya Shukla
Aishwarya Shukla 2023-4-4
Hi @Montina, To convert an array of sltest.testmanager.TestCase objects to a sltest.testmanager.TestSuite, you can also use the "add" method of the TestSuite object. Here's an example:
% Create an array of sltest.testmanager.TestCase objects
tc1 = sltest.testmanager.TestCase('myTest1');
tc2 = sltest.testmanager.TestCase('myTest2');
ts = sltest.testmanager.TestSuite('myTestSuite');
% Add test cases to the TestSuite
ts.add(tc1);
ts.add(tc2);
% Run the TestSuite
resultObj = run(ts);
In this example, we create an array of two sltest.testmanager.TestCase objects (tc1 and tc2) and then create a sltest.testmanager.TestSuite object (ts) with a name 'myTestSuite'. We then add the test cases to the TestSuite object using the "add" method. Finally, we run the resulting ts object using the run function.
I hope this helps! Let me know if you have any further questions.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Testing Frameworks 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by