Forum Discussion

arunbharath's avatar
arunbharath
Contributor
5 years ago
Solved

How to get response error from run Test case step?

         In readyAPI, we have a step called 'Run TestCase" under add step. If I use that to call another testcase, is there any way to receive the response of called test case?. Because right now I'm...
  • Radford's avatar
    5 years ago

    I'm not sure if this is what you are after, but I make extensive use of the "Run TestCase" test step. To help me debug, I always add the following to my "common" test cases tear down script:

     

    def logPrefix = testCase.getName() + ': '
    log.info (logPrefix + 'Number of results = ' + testRunner.getResults().size().toString())
    
    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) 
    		}
    	}
    }

    Is this what you are after?