我在集会上有一个测试用例。我想使用 java API 获取其中存在测试用例的测试文件夹的名称

I have a test case in rally. I want to get the name of test folder in which test case exist using java API

我尝试将测试用例作为 json 对象获取。它将测试文件夹信息作为 uri。如何在不再次点击此 uri 的情况下获取该测试文件夹的名称。

当我点击 URI 时,它会给我 TFxxx,这正是我直接需要的..

我尝试获取 jsonObj.get("TestFolder.Name").toString(); 只是 returns null。

有什么帮助吗?

在下面的代码中,我查询了一个恰好在 TestFolder 中的 TestCase,然后遍历到该文件夹​​,如下所示:

testCaseJsonObject.get("TestFolder").getAsJsonObject().get("Name")

这里是 returns TestFolder 名称的完整示例:

public class GetTestFolder {

    public static void main(String[] args) throws Exception {

        String host = "https://rally1.rallydev.com";
        String applicationName = "Example: get Folder of TestCase";
        String projectRef = "/project/12352608219";
        String apiKey = "_abc123";
        RallyRestApi restApi = null;
        try {
            restApi = new RallyRestApi(new URI(host),apiKey);
            restApi.setApplicationName(applicationName);
            QueryRequest testCaseRequest = new QueryRequest("TestCase");
            testCaseRequest.setProject(projectRef);

            testCaseRequest.setFetch(new Fetch(new String[] {"FormattedID","Name","TestFolder"}));
            testCaseRequest.setQueryFilter(new QueryFilter("FormattedID", "=", "TC47"));
            testCaseRequest.setScopedDown(false);
            testCaseRequest.setScopedUp(false);

            QueryResponse testCaseResponse = restApi.query(testCaseRequest);
            System.out.println("Successful: " + testCaseResponse.wasSuccessful());
            for (int i=0; i<testCaseResponse.getResults().size();i++){
                JsonObject testCaseJsonObject = testCaseResponse.getResults().get(i).getAsJsonObject();
                System.out.println("Name: " + testCaseJsonObject.get("Name") + " FormattedID: " + testCaseJsonObject.get("FormattedID") + " TestFolder: " + testCaseJsonObject.get("TestFolder").getAsJsonObject().get("Name"));

            }
        } finally {
            if (restApi != null) {
                restApi.close();
            }
        }
    }
}