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!