Ask a Question

Updating SLA time assertion for all the test cases in a project

SOLVED
sreelokesh
Occasional Contributor

Updating SLA time assertion for all the test cases in a project

Hi,

 

My current project structure look like this .. 

 

Project 

   -- Test suite 1

         -- 10 Test cases

   -- Test suite 2

          -- 20 Test cases

 

....

 

I had given assertion as 2sec for all the 250 test cases, I would like to know if I can change the assertion value for all test cases using a groovy script to 5sec instead of changing assertion value for each individual test case.

 

Thanks,

Lokesh

15 REPLIES 15
rupert_anderson
Valued Contributor

Hi Lokesh,

 

Have you tried setting a project level property e.g. responseTime and then using this to set the response time in all the Assertions e.g. using a property expansion ${responseTime} ?

 

Regards,

Rupert

Author of SoapUI Cookbook

Hi Rupert,

 

This is obviously how it had to be done initially, but I take it that Lokesh already has 250 tests with the hardcoded value of 2secs... 🙂

So I think that the question should be read as: "Could someone please provide me with the groovy script sample to iterate through all test steps within test project, find assertions and update the value of one of its properties (e.g. set timeout value to ${responseTime})"

 

P.S. My experience with SoapUI is quite limited and I don't have such code sample at hand (and don't need it at the moment), but if this is possible I would like to see the sample as well. (Just for my education 🙂 )

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

Hi Alex,

 

Thanks, I kind of knew that was what was being asked - for your information, Lokesh has been messaging me privately and I have already provided him with a Groovy script to copy a REST service's request body across all its POST REST Request TestSteps (250).

 

In this particular case, I could certainly enhance the Groovy script to update all Assertions across all his TestSteps, but I don't see it as the best way forward - better to set the Assertions up to use a property.

 

Of course, now that he has 250 Assertions to update - maybe a 'hacky' compromise would be to:

  • Setup the responseTime property
  • Edit the SoapUI project file XML and globally replace the "250" with ${responseTime}

Of course, please backup the project file first in case it goes wrong!

 

Thanks,

Rupert

 

 

Author of SoapUI Cookbook

Sorry Alex, forgot to add the current request copy script in case it is of any interest / use for others:

 

https://gist.github.com/bearsoftware/cfed4594dc3ae1ce7a419ca5fc9b5747

 

I was actually trying to work with Lokesh to perfect it and then I was going to blog it, but my day job is quite busy at the moment! 🙂

 

Thanks,

Rupert

Author of SoapUI Cookbook

Thank you a lot, Rupert. Pretty informative and useful! (As always from you)

And yes, I agree that direct edit of project file may be the fastest and easiest way in this given case. Great piece of advise!

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

Thanks Alex, very kind of you to say 🙂

 

If Lokesh needs the Groovy replaceall, we can work on that too!

 

Thanks,

Rup

Author of SoapUI Cookbook
nmrao
Champion Level 3

If it has to be done very quickly, I would do it in a dirty way. Be sure and careful before adopting it, there is back copy of the soapui project.

 

Close the project from SoapUI

Open the project in a favourite text editor.

Search for (change the value if it is different, when you say 2 seconds, did you put 2000?)

<token>2</token>

Try replacing it with (do not apply replace all, but still this can be quick way)

<token>${#Project#RESPONSE_TIME_SLA}</token>

 

Save the project.

Now Open the project in SoapUI

Define project level custom property RESPONSE_TIME_SLA and assign the value what ever you want.

This not helps with current change, but also for any changes in the future since it is parameterized.

 

Hope this helps.



Regards,
Rao.

Oh, I just noticed that you already proposed what I thought and added a reply.


Regards,
Rao.

No problem Rao, I think your answer is a bit better and more detailed than when I mentioned the same thing earlier! 🙂

Author of SoapUI Cookbook
cancel
Showing results for 
Search instead for 
Did you mean: