如何使用TestRail Java Client批量更新具有测试用例I的测试运行结果
这里是一个示例批量更新请求,来自add_results_for_cases()的API reference。
{
"results": [
{
"case_id": 1,
"status_id": 5,
"comment": "This test failed",
"defects": "TR-7"
},
{
"case_id": 2,
"status_id": 1,
"comment": "This test passed",
"elapsed": "5m",
"version": "1.0 RC1"
},
..
{
"case_id": 1,
"assignedto_id": 5,
"comment": "Assigned this test to Joe"
}
..
]
}发布于 2019-01-23 02:35:44
API调用
public static void addResultsForCasesAllPass(int testRunId, int... testIds)
{
APIClient client = new APIClient(BASE_URL);
client.setUser(USER);
client.setPassword(API_KEY);
JSONArray response = null;
try
{
Map data = new HashMap();
List cases = new ArrayList();
data.put("results", cases);
for ( int testId : testIds )
{
Map singleCase = new HashMap();
singleCase.put("case_id", "" + testId);
singleCase.put("status_id", "" + 5);
cases.add(singleCase);
}
String responseReq = JSONValue.toJSONString(data);
Log.d(TAG, responseReq);
Object object =
client.sendPost("add_results_for_cases/"
+ testRunId, data);
response =
(JSONArray) client.sendPost("add_results_for_cases/"
+ testRunId, data);
Log.d(TAG,"response = "+response.toJSONString());
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( APIException e )
{
e.printStackTrace();
}
}和变量
public static final String USER = "firstName.lastName@company.com";
public static final String API_KEY = "/asdsdsd-k9yTR8cxxxxd5uj";
public static final String BASE_URL = "https://my.testRail.io/";还要记住通过测试轨道站点中的管理选项卡启用API密钥
https://stackoverflow.com/questions/54314485
复制相似问题