How to convert an array of sltest.testmanager.TestCase to sltest.testmanger.TestSuite?
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).
0 个评论
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 Testing Frameworks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!