skelkar
11 years agoContributor
How to log RequestIds for all failed test steps
Hi,
I would like to capture and log requestIds of all failed test steps from all test cases in a test suite.
Any idea how to achieve that.
I tried adding below script into test suite tear down script but no luck.
for ( testCaseResult in runner.results )
{
testCaseName = testCaseResult.getTestCase().name
log.info testCaseName
if ( testCaseResult.getStatus().toString() == 'FAILED' )
{
for ( testStepResult in testStepResult.getResults() )
{
if ( testStepResult.getStatus().toString() == 'FAILED' )
{
testStepName = testStepResult.getTestStep().name
log.info testStepName
String ReqId = testRunner.testCase.testSteps[testStepName].testRequest.response.responseHeaders["RequestId"]
ReqId=ReqId.replaceAll("\\[", "")
ReqId=ReqId.replaceAll("\\]", "")
log.info "ReqId : " + ReqId
}
}
}
}
Please advise.
Suraj
I would like to capture and log requestIds of all failed test steps from all test cases in a test suite.
Any idea how to achieve that.
I tried adding below script into test suite tear down script but no luck.
for ( testCaseResult in runner.results )
{
testCaseName = testCaseResult.getTestCase().name
log.info testCaseName
if ( testCaseResult.getStatus().toString() == 'FAILED' )
{
for ( testStepResult in testStepResult.getResults() )
{
if ( testStepResult.getStatus().toString() == 'FAILED' )
{
testStepName = testStepResult.getTestStep().name
log.info testStepName
String ReqId = testRunner.testCase.testSteps[testStepName].testRequest.response.responseHeaders["RequestId"]
ReqId=ReqId.replaceAll("\\[", "")
ReqId=ReqId.replaceAll("\\]", "")
log.info "ReqId : " + ReqId
}
}
}
}
Please advise.
Suraj