Rally: Java: I have few test folders inside a test folder and all folders have test cases. How to get all the test cases using java api

帅比萌擦擦* 提交于 2019-12-22 12:05:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!