cancel
Showing results for 
Search instead for 
Did you mean: 

API script assertion not running when running from testcase although run from step is success

Highlighted
Occasional Contributor

API script assertion not running when running from testcase although run from step is success

I have a testcase with one API for which Script assertion is used to ready the ReadyAPI log.

This script runs and passes the step when run from the step directly.

But when i run from the testcase level, it fails, not sure why this occurs.

My requirement is to run the script irrespective of pass or fail of the request because my script is reading the log to understand that.

The API request and script are as follows:


image.png

//https://community.smartbear.com/t5/SoapUI-Open-Source/How-to-read-Request-log-from-groovy/td-p/29362#
def logArea = com.eviware.soapui.SoapUI.logMonitor.getLogArea("ReadyAPI Log");
def model = logArea.model
if (model.size > 0) {
   val = false
   for (c in 0..(model.size - 1)) {
       if (String.valueOf(model.getElementAt(c)).contains("Connection refused: connect")){
       	log.info(model.getElementAt(c))
       	val = true
          break
       } 
     }
     if(val != true) {
     	throw new Exception("Assertion failed")
     }
  }
  else {
  	throw new Exception("Assertion failed here")
  }

 

Share Your Stories
Read Latest News
Top Kudoed Authors