问题
In a rally project, I have the test folder structure as below
TestFolderParent1 testcase1, testcase2..... testcase5 TestFolderChild1 testcase10, testcase11..... testcase15 TestFolderChild2 testcase20, testcase21..... testcase25
Am using java api to filter as below:
QueryRequest testSetRequest = new QueryRequest("TestCases");
testSetRequest.setFetch(new Fetch(new String[] { "Name","FormattedID"}));
testSetRequest.setQueryFilter(new QueryFilter("TestFolder.Name", "=", "TestFolderParent1"));
If I print all the test cases from the response.. it gives only testcase1, testcase2..... testcase5
How to get all the test cases which are under subfolders of TestFolderParent1 also.
Thanks, Venkatesh
回答1:
In this case you could add another clause to your query to account for the grandparent case:
QueryFilter children = new QueryFilter("TestFolder.Name", "=", "TestFolderParent1");
QueryFilter grandChildren = new QueryFilter("TestFolder.Parent.Name", "=", "TestFolderParent1");
testSetRequest.setQueryFilter(children.Or(grandChildren));
This gets clumsy pretty quickly if you have a super deep hierarchy of test folders but should work alright for the case you have mentioned...
回答2:
Your code is good enough but slight modification will fetch your required results. TestFolder.Parent.Name
will fetch you all test cases from that particular folder irrespective of number of child folders.
QueryRequest testSetRequest = new QueryRequest("TestCases");
testSetRequest.setFetch(new Fetch(new String[] { "Name","FormattedID"}));
testSetRequest.setQueryFilter(new QueryFilter("TestFolder.Parent.Name", "=", "TestFolderParent1"));
来源:https://stackoverflow.com/questions/37463418/rally-java-i-have-few-test-folders-inside-a-test-folder-and-all-folders-have-t