gpt4 book ai didi

java - 在 Rally 中如何获取测试集中测试用例的执行状态

转载 作者:行者123 更新时间:2023-11-30 08:28:38 24 4
gpt4 key购买 nike

我想使用 Rally Java API 获取测试集中测试用例的执行状态。以下代码段返回测试用例的最后执行状态。但我想要特定测试集中该测试用例的执行状态。

    QueryRequest testSetRequest = new QueryRequest("TestSet");

testSetRequest.setFetch(new Fetch(new String[] { "Name", "TestCases",
"FormattedID", "LastVerdict","LastRun" }));

testSetRequest.setQueryFilter(new QueryFilter("Name", "=", tsName));

QueryResponse testSetQueryResponse = restApi.query(testSetRequest);
System.out.println("Successful: "
+ testSetQueryResponse.wasSuccessful());
System.out.println("Size: "
+ testSetQueryResponse.getTotalResultCount());
for (int i = 0; i < testSetQueryResponse.getResults().size(); i++)
{
JsonObject testSetJsonObject = testSetQueryResponse.getResults()
.get(i).getAsJsonObject();
System.out.println("Name: " + testSetJsonObject.get("Name")
+ " ref: " + testSetJsonObject.get("_ref").getAsString()
+ " Test Cases: " + testSetJsonObject.get("TestCases"));
int numberOfTestCases = testSetJsonObject.get("TestCases")
.getAsJsonArray().size();
System.out.println(numberOfTestCases);
if (numberOfTestCases > 0)
{
for (int j = 0; j < numberOfTestCases; j++)
{
JsonObject tcObj = testSetJsonObject.get("TestCases")
.getAsJsonArray().get(j).getAsJsonObject();
System.out.println(tcObj.get("FormattedID")+"----"+tcObj.get("LastVerdict"));
}
}
}

最佳答案

    QueryRequest testCaseResultsRequest = new QueryRequest("TestCaseResult");
testCaseResultsRequest.setFetch(new Fetch("Build","TestCase","TestSet", "Verdict","FormattedID"));
testCaseResultsRequest.setQueryFilter(new QueryFilter("TestCase.FormattedID", "=", "TC8147").and(
new QueryFilter("TestSet.FormattedID", "=", "TS363")));
QueryResponse testCaseResultResponse = restApi.query(testCaseResultsRequest);
int numberTestCaseResults = testCaseResultResponse.getTotalResultCount();
System.out.println(numberTestCaseResults);
if(numberTestCaseResults >0)
System.out.println(testCaseResultResponse.getResults().get(0).getAsJsonObject().get("Verdict").getAsString());
else
System.out.println("Not executed");

关于java - 在 Rally 中如何获取测试集中测试用例的执行状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20089705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com