How to retrieve the test case ID or TCID from Rally using Rally REST API
Trying to integrate Rally using Java, then you are reading the right post.
Download the jars needed which would be:
- rally-rest-api-2.0.1.jar
- gson-2.2.4.jar
The code below takes the TCID as the input and returns a reference to the test case that you can use as need be.
String host = "https://rally1.rallydev.com";
String username = configProp.getProperty("RallyUserName");
String password = configProp.getProperty("RallyPassword");
String wsapiVersion = "v2.0";
String workspaceRef = "/workspace/11111";
String applicationName = "Rest_FindTC";
RallyRestApi restApi = new RallyRestApi(
new URI(host),
username,
password);
restApi.setWsapiVersion(wsapiVersion);
restApi.setApplicationName(applicationName);
// Query to get the ref from Rally for the test case
QueryRequest testCaseRequest = new QueryRequest("TestCase");
testCaseRequest.setFetch(new Fetch("FormattedID","Name"));
testCaseRequest.setWorkspace(workspaceRef);
testCaseRequest.setQueryFilter(new QueryFilter("FormattedID", "=", TCID));
QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);
String testCaseRef = testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").getAsString();
testCaseRef = testCaseRef.replace("https://rally1.rallydev.com/slm/webservice/v2.0/testcase/", "");
logger.debug("For the Rally TCID: "+TCID+ " retreived from Rally the ID - "+testCaseRef);
restApi.close();
In the above code TCID is the parameter that is passed which has the rally test case id. and testCaseRef is what is returned
Happy automated integration!
I have read your blog its very attractive and impressive. I like your blog
ReplyDeleteselenium Online Course