When I execute a test case or test suit, I would like to get the test status (pass/Fail) and save it to a global variable. I would then send a REST call that will update my test status on crossbrowsertesting.com .
Please search for this question on the forum “How to use tearDownIfPassed and tearDownIfFailed” This helped me.
@TearDownIfPassed
def handlePassed() {
println('Handle Passed')
WebUI.closeBrowser() GlobalVariable.CBT_pass_fail_status = 'pass' WebUI.callTestCase(findTestCase('Get Selenium ID from CBT'), [:], FailureHandling.STOP_ON_FAILURE) WebUI.callTestCase(findTestCase('Set test score on CBT'), [:], FailureHandling.STOP_ON_FAILURE)
} @TearDownIfFailed
def handleFailure() {
println('Handle Failure')
WebUI.closeBrowser() GlobalVariable.CBT_pass_fail_status = 'fail' WebUI.callTestCase(findTestCase('Get Selenium ID from CBT'), [:], FailureHandling.STOP_ON_FAILURE) WebUI.callTestCase(findTestCase('Set test score on CBT'), [:], FailureHandling.STOP_ON_FAILURE)