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")
  }

 

1 REPLY 1
Occasional Contributor

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

Hello.

 

In soapui 5.4.0 version, i don't have "ReadyAPI Log". 

I put your script with "script log" and it runs well, in all cases.

val = true case , val = false or model.size = 0

Tue Dec 11 13:09:06 CET 2018:INFO:Tue Dec 11 13:09:06 CET 2018:INFO:Connection refused: connect

 

So witch version do you use ? take care on upper and lower case in "ReadyAPI Log" value..

 

Top Kudoed Authors