Parsing Test Manager Information with Nested Folders
2 次查看(过去 30 天)
显示 更早的评论
I have a test Manager set up with cases as follows in teh folder structure for example.
Tests
General
ConfigA
Test Case1
Test Case2
Config B
Test Case1
Test Case2
Extreme
ConfigA
Test Case1
Test Case2
Config B
Test Case1
Test Case2
My scripts in the past were successful in looping through all the cases to get and update values. I am not nested in the folders one level deeper and I cannot find a way for this to work.
Previously it looked like this
Tests
Config A
Test Case1
Test Case2
ConfigB
Test Case 1
Test Case 2
I have reorganize to be only one level folder deep for now as before, but there are reasons why I would want to organize it differently that maybe this simple example does not show it the best.
Here is what my script looks like. It no longer finds all the test cases such to loop through them because they are nested a folder deeper now. I am thinking it is a limit of the function API to the Test Manager. This is a little advanced for my current skill level so maybe I am missing something.
% Read source file
tf = sltest.testmanager.TestFile(testFile);
ts = getTestSuites(tf);
TestCaseArray = GetTestCaseArray(ts);
[~, TestCaseSize] = size(TestCaseArray);
for i=1:TestCaseSize
%Do something for each test case.
end
Thanks ... thought I may ask before I post it as a improvment if that is what it turns out to be.
0 个评论
采纳的回答
Swetha Murali
2022-7-11
I think the logic maybe in the way "GetTestCaseArray" function works. Here is one I wrote that will work for either one of these test structures
function allTestCases = getAllTestCaseObjectsInTestFile(testFileName)
tf = sltest.testmanager.TestFile(testFileName);
ts = getTestSuites(tf);
allTestCases = getTestCaseFromTestSuite(ts);
end
function tc = getTestCaseFromTestSuite(ts)
% Recursively get all test cases from testsuites in a nested folder
% structure
tc = [];
for i=1:numel(ts)
tc = [tc,getTestCases(ts(i))];
subts = getTestSuites(ts(i));
tc = [tc,getTestCaseFromTestSuite(subts)];
end
end
You can try replacing your code with a call to the above function, something like this:
TestCaseArray = getAllTestCaseObjectsInTestFile(testFile);
[~, TestCaseSize] = size(TestCaseArray);
for i=1:TestCaseSize
%Do something for each test case.
end
0 个评论
更多回答(1 个)
Mark McBroom
2022-7-11
Try using this syntax to get all test cases in a nested folder structure:
suite = TestSuite.fromFolder(pwd, 'IncludingSubfolders', true);
result = run(suite);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Outputs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!