Forum Discussion

meetu1's avatar
meetu1
New Contributor
6 years ago

Asserting response at project level

Hi,

I have lot of requests in my test suite on which I am asserting the http status code and status of my response. Is it possible to add a common assertion or groovy script at project or test suite level which will run for all test steps if assertions are same for all test steps.

 

Thanks

3 Replies

  • Hi meetu1,

     

    I think this approach of asserting the response at Test Suite Level is not good because you will come to know about any Environment down or other issues after the execution of each and every Test Case.

     

    Best Approach is assert each and every Request you are adding into Test Case.

     

    For the Solution of your Scenario:

     

    Write a groovy class with assertions that you want to include , make a jar and place it in the {{..\bin\ext}} folder of SoapUI/ReadyAPI. 

    Restart SoapUI/ReadyAPI. 

    Go to the request step and add script assertions, import groovy class and invoke the assertion method written in jar.

     

    Do Like if you Find this as solution

     

    Thanks,

    Himanshu Tayal

    • meetu1's avatar
      meetu1
      New Contributor

      Thanks HimanshuTayal I already have script assertions at the request level but was wondering if there is any way to add them at project level as all my requests have similar assertions so instead of adding assertion at each request if I could use some event listener which would assert the response of each request.

  • jhanzeb1's avatar
    jhanzeb1
    Frequent Contributor

    Good question. The simple answer would be - not at a project or testsuite level. However, I understand you do not want to keep repeating same thing everywhere so therefore you could have a groovy script in a class to assert for your response code and all you have to do is to ensure you call that script from the script library in your responses.

     

    https://www.soapui.org/scripting-properties/scripting-and-the-script-library.html

    Might be able to help you :)