David_Shapiro
15 years agoOccasional Contributor
How to Capture errors?
I have a fairly simply script, but I want to improve it so that it shows the error seen in its testStep. I am not sure how to do this. I tried (see code below) to put result.error, but that does not work. Is there something like result.error or result.stderr or something?
/ Set the testcase name
def testcase = "order";
def request = testRunner.testCase.getTestStepByName(testcase);
def results = testRunner.results;
//assert results.size() != 0, sendAlert('Results are missing from request for ' + testcase);
def sendAlert(msg)
{
// codes sends an alert here
}
for (result in results)
{
if (result.testStep == request)
{
log.info("request status: " + result.status);
// Set status that you want alert to go out on here
if (!(result.status ==~ /OK/))
{
[color=green]// Instead of putting result.status, I would like to put the error message[/color]
sendAlert("Alert for " + testcase + ": " + [color=green]result.status[/color]);
}
}
}