Forum Discussion
I want to create script which will create request
One step at a time. How this request looks like? Is it fixed always? or changes values?
Yes, I am getting value from each Testcase Property and assign to Zephyr scale api parameter I am trigging this aftertestCase event, below is my script but it's not working in event
def tcobject = testCaseRunner.getTestCase()
def tsobject = testCaseRunner.getTestCase().testSuite
def projobject = testCaseRunner.getTestCase().testSuite.project
def stepList = tcobject.getTestStepList();
// // Get all test cases’ names from the suite
def testCaseName = tcobject.name;
def testCaseID = projobject.getPropertyValue("testCaseKey")
def testCycleID = projobject.getPropertyValue("TestCycleID");
def projectKey = projobject.getPropertyValue("projectID")
testcaseStatus=tcobject.getPropertyValue("tcstatus")
log.info("testCaseName"+testCaseName)
log.info("projectKey1"+projectKey)
log.info("testcaseKey1"+testCaseID)
log.info("testcycleKey1"+testCycleID)
log.info("statusinpost1"+testcaseStatus)
log.info(projectKey.length() )
log.info(testCaseID.length() )
// log.info "projectKey : $projectKey , TestCaseName : $testCaseName , TestCaseIID : $testCaseID, TestCycleID: $testCycleID , ";
if (testCaseID == null || testCaseID.length() == 0 || testCycleID == null || testCycleID.length() == 0 || projectKey == null || projectKey.length() == 0) {
log.info "MANDATORY FIELDS NOT AVAILABLE. Please check Ready API script to confirm they have all fields defined"
return 0
}
// testcaseStatus="PASS"
//testRunner.getResults()
log.info(testcaseStatus)
// Check whether the case has failed
if (testcaseStatus == 'FAIL') {
// Log failed cases and test steps’ resulting messages
log.info "$testCaseName has failed"
for (testStepResult in testCaseRunner.getResults()) {
testStepResult.messages.each() {
msg -> log.info msg
}
}
postToZephyrScale(projectKey, testCaseID, testCycleID, "Fail")
} else if (testcaseStatus == 'PASS') {
postToZephyrScale(projectKey, testCaseID, testCycleID, "Pass")
log.info "$testCaseName Test Passed";
}
// log.info "Results updation to Jira is complete"
//String projectKey, String testcaseKey, String testcycleKey, String status, String comment)
def postToZephyrScale( String projectKey, String testcaseKey, String testcycleKey, String status ){
def today = new Date()
def formattedDate = today.format("yyyy-MM-dd'T'HH:mm:ssZ")
log.info("postToZephyrScale")
log.info("projectKey"+projectKey)
log.info("testcaseKey"+testcaseKey)
log.info("testcycleKey"+testcycleKey)
log.info("statusinpost"+status)
def project = testRunner.testCase.testSuite.project
def requestTc = project.testSuites["UpdateTCsStatus Suite"].testCases["TestExecutions Test Case"]
def requestSTP = requestTc.getTestStepByName("StatusUpdate")
def request = requestSTP.getHttpRequest()
requestSTP.setPropertyValue("testCaseKey",testcaseKey.toString )
requestSTP.setPropertyValue("status",status.toString )
runner=requestSTP.run(testCaseRunner,context)
// log.info ("runner status ....:"+ runner.hasResponse())
}
Related Content
- 12 months ago