Jira by default is a 'Defect Management Tool'. However, available add-on for Jira make it much more capable than just defect Management tool. Couple of such add-ons like 'Zephyr For Jira' & 'ZAPI' (API to access data from 'Zephyr For Jira' programmatically) make Jira capable for 'Test Management'. Both of these add-ons have different version for Server & Cloud accordingly. Let us look at, how do we work with ZAPI server version.
This example shows how to consume ZAPI REST APIs from Java using REST Assured libraries.
Step 1: Create a Project with dependent REST assured libraries.
NOTE: For the set up / usage of REST assured libraries can be found in another post.
https://advancedtestautomation.blogspot.in/2016/08/test-rest-web-services-using-rest.html
Step 2: Create a class file by name 'ZAPIConnect'.
Step 3: Define a main method with the below variables.
RestAssured.baseURI = "https://testserver.atlassian.net/rest/zapi";
String UpdateIssueUrl = "/latest/execution/updateBulkStatus";
HashMap<String,String> headerMap = new HashMap<String,String>();
headerMap.put("Content-Type", "application/json");
headerMap.put("Authorization", "Basic bmC5jb20sdsYWtpbmczMjE=");
String statusPaylod = "{\"executions\":[\"12345\"],\"status\":\"PASS\"}";
Step 4: Create a method 'updateIssue' to update the execution status:
public static void updateIssue(String url, HashMap<String,String> headerMap, String body){
Response response = null;
try{
response = RestAssured.given().log().all().headers(headerMap).body(body).put(url);
response.prettyPrint();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
Step 5: Call the methods 'updateIssue' in main method accordingly.
Similar to the above, many such methods are available to perform actions on ZEPHYR tests thorough ZAPI REST APIs.
References:
https://getzephyr.docs.apiary.io
Use Case: Whenever the automation is run, it has to update the status of execution in test cycle.
Pre-requisite: Manual Tests are created in Jira with Issue Type - Test & Test cycle is created with tests added into it (Adding tests into test cycle creates execution ids for each test case in test cycle).
High Level Steps:- Login to Jira using proper credentials.
- Provide the Cycle Id OR ProjectId,Version & Cycle Id of the Test cycle to ZAPI api.
- Update the Test case status in test cycle based on the execution id of each test case.
Example to Update Status of Test case execution Using ZAPI API:
This example shows how to consume ZAPI REST APIs from Java using REST Assured libraries.
Step 1: Create a Project with dependent REST assured libraries.
NOTE: For the set up / usage of REST assured libraries can be found in another post.
https://advancedtestautomation.blogspot.in/2016/08/test-rest-web-services-using-rest.html
Step 2: Create a class file by name 'ZAPIConnect'.
Step 3: Define a main method with the below variables.
RestAssured.baseURI = "https://testserver.atlassian.net/rest/zapi";
String UpdateIssueUrl = "/latest/execution/updateBulkStatus";
HashMap<String,String> headerMap = new HashMap<String,String>();
headerMap.put("Content-Type", "application/json");
headerMap.put("Authorization", "Basic bmC5jb20sdsYWtpbmczMjE=");
String statusPaylod = "{\"executions\":[\"12345\"],\"status\":\"PASS\"}";
Step 4: Create a method 'updateIssue' to update the execution status:
public static void updateIssue(String url, HashMap<String,String> headerMap, String body){
Response response = null;
try{
response = RestAssured.given().log().all().headers(headerMap).body(body).put(url);
response.prettyPrint();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
Step 5: Call the methods 'updateIssue' in main method accordingly.
Similar to the above, many such methods are available to perform actions on ZEPHYR tests thorough ZAPI REST APIs.
References:
https://getzephyr.docs.apiary.io
i need little help from you on keystore (soap services), can you message me
ReplyDeleteabdulmominshaik@gmail
ReplyDeleteI want the test execution status from Zephyr automatically update a Status field in Jira, is that possible?
ReplyDelete