Ask a Question

How to add Assertions with Groovy Script

Regular Contributor

How to add Assertions with Groovy Script



I've received a Groovy Script from @nmrao for my project. It actually implements a workarround for project where you will have a lot of parameters to use. Parameters in ReadyAPI (I don't know if this it also the fact in soapui open source) are set generaly in the tab 'Projects' on the webservice itself. Now if you project grows, you can end up with 500 different parameters and unbelievable much combinations of testcases. That's a not done situation for a tester. @richie  has already created an enhancement for this but for now we need a workarround to go on with.

So therefore the script.

I was looking at it and I was wondering how we could create assertions for a groovy script, so I started to look arround but I've noticed that apparently there are a lot of snippets for different purposes but mostly for soapui open source, as " is not a SOAP fault" doesn't exist in ReadyAPI.

Therefore my question:

How can I insert an assertion in groovy script to check wether the response of my Groovy Script is :

  • schema compliant
  • if it has more then 1 response
  • if a particular name or number is found
  • if an error message is thrown

I hope to get some response already, so thanks for your time in advance.




Champion Level 3

No need to add separate assertions groovy script test step like other request test steps. Because, assertions can be added in side groovy script itself.

Regular Contributor

Hi @nmrao ,


Yes, I understood this, but how should I write this for the checks that I want please?

Community Hero

Hey ,

What you're asking for is a lot of work....also you are asking for multiple discrete verifications, which could be perceived as too much work for the scripters on the forum to help...your reqs could beover a days worth of work (depending how good the coder is).

What you need to do is create separate posts for each verification you need and hopefully people can help with discrete chunks of work.

Finally. You should always supply enough info for the forum members to assist.
Theyll typically need the use case, what youre trying to do, why you havent used the out of the box functionality if its available and request and response payloads for each of your 4 or 5 scripting requirements.
The forum members need all this, because this detail will impact the groovy thst is required.

I hope this explains things,


if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Regular Contributor


Wow, I didn't knew that! a days work? Yaks  😞  

But thanks for the explanation Richie. I'll discuss that with my client on what is priority for now. Then I can indeed post several more little posts for each assertion.




Showing results for 
Search instead for 
Did you mean: