Refactoring a Request so it change in all its test cases
I have been using the unlisenced version of SoapUI for a couple of weeks, up until I encountered this problem.
I built a project full of REST requests, each of them with a json body with different data. After doing this, I build multiple test cases, each of these featuring those request and adding those asserts. But now, after 20 hours of work, I find out that whenever change I make on those requests, doesn't change on the tests cases, which means that I would have to manually modify 30 tests, each of them with 10+ requests.
While researching I found out that the PRO version of the application allows you to do that, and so I got a trial versiĆ³n to figure out if it does. I created a new proyect, added a new request, defined a json body, and then added a simple test with just that request. No matter the times I change the original request, it doesn't change on the test case. Refactoring ask me for a WADL which I don't have, nor do I plan to have, I just want to change the values of the fields on my json request.
I'll add some examples.
This is my request, it is called T0S0_Basic_Valid, and it send different values, one of them being "origin", which was "SEI", and now I want "BUS". I also added a parameter for the value "client", which was hardcoded, but now I need it to be able to change.
This is my test case. One of the first steps is calling this request, T0S0_Basic_Valid. Now, as you can see, the values didn't change, so now I have to manually change them.
As you can see, I have many similar requests (T1S1, T2S1, etc). Each of them have a similar structure, but they change their inner values, maybe adding new fields on the JSON. I cannot make them all parameters, nor can I constantly change their value inside each test case, as I will requiere to change the request for time to time.
Is there any solution? How can I refactor these requests?
Thank you.
So, here's an example of what I mean. Some of the SOAP services I test as part of my job can go through what I call "schema churn." Where there is a defect with the WSDL/XSD files that cause new versions to be put out. Sometimes these new WSDL/XSD files are 99.9% the same and only change how an element is define (regex pattern, etc.)
The problem is when these WSDL/XSD files change significantly enough that the actual XML of the requests has new elements or some are no longer present. This means that all of my tests (sometimes hundreds of them) need to change. This is problematic because of what you said. It's tedious and untenable to have to manually update these tests.
I have written a groovy script that can, with the right setup, take a request, or the content thereof, make the necessary changes and save it back to the test step. So let's say I have an old WSDL/XSD set that has the following element:
<element> <child1/> <child2/> <child3/> </element>
And all of my tests are based off of that. Let's say the new WSDL/XSD file has:
<element> <child1/> <child2/> <child3> <grandchild1/> <grandchild2/> </child3> </element>
That means all of my tests are now out of date. So I would write a groovy script that steps through every test suite in the project, every test case in each test suite, and each test step in each test case. If the test step needs to be updated (you will need to have the appropriate groovy logic in place for this), you will do :
// Psuedocode def oldRequest = testStep.getRequestContent(); def newRequest = oldRequest.replaceAll("<child3/>", <child3>\n<grandchild1/>\n<grandchild2>"); testStep.setRequestContent(newRequest);