下面的代码是用于创建一个新的测试运行,在testail中包含所有选项,它从项目中选择所有测试用例。如果我只想为我的测试运行选择一组特定的测试用例,如何添加?
public static void createSuite() throws IOException, APIException {
//Login to API
client = new APIClient("https://swtestacademy.testrail.io");
client.setUser("canberkakduygu@gmail.com");
client.setPassword("Qwerty_123");
//Create Test Run
Map data = new HashMap();
data.put("include_all",true);
data.put("name","Test Run "+System.currentTimeMillis());
JSONObject c = (JSONObject)client.sendPost("add_run/"+PROJECT_ID,data);
//Extract Test Run Id
runId = (Long)c.get("id");
}
参考https://www.gurock.com/testrail/docs/api/reference/runs
为了从测试套件中选择自定义测试用例列表,您应该为"include_all"使用false然后添加一个自定义案例id数组。
示例(来自上面的页面):{"suite_id" 1、名称";这是新的测试运行"assignedto_id" 5ref ";SAN-1, SAN-2"include_all"假的,case_id ": [1,2,3,4,7,8]}
您可以这样添加(它对我有效):
List list = Arrays.asList("1919581");
Map<String, Serializable> data = new HashMap<>();
data.put("suite_id", 8116);
data.put("name", "Auto add run");
data.put("include_all", false);
data.put("case_ids", (Serializable)list);
JSONObject r = (JSONObject) client.sendPost("add_run/17", data);