Forum Discussion

krogold's avatar
krogold
Regular Contributor
6 years ago

Is it possible to get a 'call stack' in readyAPI ?

Hello,   I use generic test cases as common methods for my other test cases. When one of them fail, I can get some information, but mainly I get a generic error return with no detail of what hap...
  • Radford's avatar
    6 years ago

    I too use a set of "common" test cases for reusable functionality. While not a "call stack", I put the following code into my common library test case tear down scripts:

     

    def logPrefix = testCase.getName() + ': '
    
    for(result in testRunner.getResults()){
    	if(result.getStatus().toString() != 'PASS' ){
    		def failedTestStepName = result.getTestStep().getName()
    		def logPrefixStep = logPrefix.trim() + failedTestStepName + ': '
    		
    		log.error(logPrefixStep + 'TestStep "' + failedTestStepName + '" finished with the status ' + result.getStatus().toString())
    
    		for(testProperty in testCase.getTestStepByName(failedTestStepName).getPropertyList()){
    			if(testProperty.isReadOnly()){
    				log.info(logPrefixStep + 'Output property: ' + testProperty.getName() + ' = ' + testProperty.getValue())
    			}else{
    				log.info(logPrefixStep + 'Input property: ' + testProperty.getName() + ' = ' + testProperty.getValue())
    			}
    		}
    		
    		for(message in result.getMessages()){
    			log.error(logPrefixStep + 'Error message: ' + message) 
    		}
    	}
    }

    This usually provides me with the information I require to debug.