gpt4 book ai didi

java - Rally RestAPI-无法更新测试集结果

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

虽然我能够提取特定测试集中存在的所有测试用例并修改或更新所有测试结果。更新该测试集中的测试用例后,测试集未反射(reflect)结论(通过/失败)。

如果我导航到其中一个 tescase 详细信息页面,我能够看到更新的测试用例结果

这是更新测试用例后的测试集状态 test-set status after updating the testcases

但是当打开其中一个测试用例时,我能够看到更新的测试用例结果

updated testcase result

代码: QueryRequest testSetRequest = new QueryRequest("TestSet"); testSetRequest.setFetch(new Fetch(new String[] {"Name", "TestCases", "FormattedID"}));

    testSetRequest.setQueryFilter(new QueryFilter("FormattedID", "=", "TS346"));

QueryResponse testSetQueryResponse = restApi.query(testSetRequest);

if(testSetQueryResponse.wasSuccessful()){

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").getAsJsonObject().get("_ref"));

int numberOfTestCases = testSetJsonObject.get("TestCases").getAsJsonObject().get("Count").getAsInt();
System.out.println(numberOfTestCases);
if(numberOfTestCases>0){
QueryRequest testCaseRequest = new QueryRequest(testSetJsonObject.getAsJsonObject("TestCases"));
testCaseRequest.setFetch(new Fetch("FormattedID"));
//load the collection
JsonArray testCases = restApi.query(testCaseRequest).getResults();
for (int j=0;j<numberOfTestCases;j++){
System.out.println(testCases.get(j).getAsJsonObject().get("FormattedID").getAsString());
String s= testCases.get(j).getAsJsonObject().get("FormattedID").getAsString();
testCaseRequest = new QueryRequest("TestCase");
testCaseRequest.setFetch(new Fetch("FormattedID","Name"));
testCaseRequest.setQueryFilter(new QueryFilter("FormattedID", "=", s));
QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);
String testCaseRef = testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").getAsString();

try{
//Add a Test Case Result
System.out.println("Creating Test Case Result...");
JsonObject newTestCaseResult = new JsonObject();
newTestCaseResult.addProperty("Verdict", "Pass");
newTestCaseResult.addProperty("Date", "2013-11-29T18:00:00.000Z");
newTestCaseResult.addProperty("Notes", "Automated Selenium Test Runs");
newTestCaseResult.addProperty("Build", "208");
newTestCaseResult.addProperty("TestCase", testCaseRef);

CreateRequest createRequest = new CreateRequest("testcaseresult", newTestCaseResult);
CreateResponse createResponse = restApi.create(createRequest);

if(createResponse.wasSuccessful()){
System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));
//Read Test Case
String ref = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
System.out.println(String.format("\nReading Test Case Result %s...", ref));
GetRequest getRequest = new GetRequest(ref);
getRequest.setFetch(new Fetch("Date", "Verdict"));
GetResponse getResponse = restApi.get(getRequest);
JsonObject obj = getResponse.getObject();
System.out.println(String.format("Read Test Case Result. Date = %s, Verdict = %s", obj.get("Date").getAsString(), obj.get("Verdict").getAsString()));
} else {
String[] createErrors;
createErrors = createResponse.getErrors();
System.out.println("Error occurred creating Test Case: ");
for ( i=0; i<createErrors.length;i++) {
System.out.println(createErrors[i]);
}
}
}
finally{

}
}
}
}
}
else {
String[] createErrors;
createErrors = testSetQueryResponse.getErrors();
System.out.println("Error occurred creating Test Case: ");
for (int i=0; i<createErrors.length;i++) {
System.out.println(createErrors[i]);
}
}

所以,关于如何更新测试集结果的任何想法

最佳答案

只需要在新的测试用例结果中添加下面的代码

newTestCaseResult.addProperty("测试集", testsetref);

关于java - Rally RestAPI-无法更新测试集结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20281308/

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