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