Ask a Question

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

niravk17
Occasional Contributor

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 4
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
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 

Radford
Super Contributor

Sorry, I'm not sure I understand you when you say "its printing finished status not  failed", the TestStepResult method getStatus() returns an TestStepResult.TestStepStatus enumeration:

 

http://www.soapui.org/apidocs/com/eviware/soapui/model/testsuite/TestStepResult.html

 

This can only be one of four things:

 

  1. CANCELED 
  2. FAILED 
  3. OK 
  4. UNKNOWN 

I have not experimented with the "Abort on Error" option, perhaps "Fail TestCase on Error" is also worth investigating?

I believe that you do not have to check each and every step to see if the test is passed or not, if I got your issue right.

Please see(Message 11 of 14) if the script provided in this thread is helpful in your case.
https://community.smartbear.com/t5/SoapUI-NG/Adding-new-test-step-for-all-test/m-p/105907/highlight/...


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: