Forum Discussion
skillsoft
13 years agoFrequent Contributor
If I put the same code in a groovy step it's not returning the failure back to the calling test case. It seems that putting it in the teardown script is the best solution. I've tried using various events as well with no luck. Any suggestions?
I'm calling a method in a class. The method's code is here (I got it from this forum and modified it a bit):
def static getErrors(sname,testRunner,log )
{
def results = testRunner.results
log.info( "Checking " + results.size() + " TestStepResults.." )
def c = 0;
while( c < results.size() )
{
if( results[c].status.toString() == "FAILED" )
{
break;
}
c++
}
// failed?
if( c < results.size() )
{
assert false, "Failure in TestStep [" + results[c].testStep.name + "] for " + sname + " with this message"+results[c].messages
/*for( msg in results[c].messages )
{
//log.info(c+": "+msg )
assert false, results[c].testStep.name+" failed for "+sname+ " with this message"+ msg
}
*/
}
}
I'm calling a method in a class. The method's code is here (I got it from this forum and modified it a bit):
def static getErrors(sname,testRunner,log )
{
def results = testRunner.results
log.info( "Checking " + results.size() + " TestStepResults.." )
def c = 0;
while( c < results.size() )
{
if( results[c].status.toString() == "FAILED" )
{
break;
}
c++
}
// failed?
if( c < results.size() )
{
assert false, "Failure in TestStep [" + results[c].testStep.name + "] for " + sname + " with this message"+results[c].messages
/*for( msg in results[c].messages )
{
//log.info(c+": "+msg )
assert false, results[c].testStep.name+" failed for "+sname+ " with this message"+ msg
}
*/
}
}