Forum Discussion

niravk17's avatar
niravk17
Occasional Contributor
8 years ago

how to write teardown script to print out test step status Pass or fail ?

how to write teardown script to print out test step status Pass or fail ?

4 Replies

  • Radford's avatar
    Radford
    Super Contributor

    The following is a Test Case teardown script that iterates through all the test steps might help out:

     

     

    for(result in testRunner.getResults()){
     if(result.getStatus().toString() != 'OK' ){
      def failedTestStepName = result.getTestStep().getName()
      
      log.error('TestStep "' + failedTestStepName + '" finished with the status ' + result.getStatus().toString())
    
      for(testProperty in testCase.getTestStepByName(failedTestStepName).getPropertyList()){
       log.info(testProperty.getName() + ' = ' + testProperty.getValue())
      }
    
      for(message in result.getMessages()){
       log.error('Error message: ' + message)
      }
     }
    }
    • niravk17's avatar
      niravk17
      Occasional Contributor

      Thank you Radford .

      While execution of test case one of my assertion step get fail but still process of execution is 'Finished " and its printing finished status not  failed 

      If you opt out Abort on failed test cases its still log as "finished" instead of failed 

      Please find the attchment