Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOAPUI - configure endpoints and resources for TestCase/TestSuite

Tags:

soapui

Is there a way to configure the resource/method used by requests in tests on a test case, test suite or even project level in SOAPUI (free)?

We have the following use case:
The same REST service running on different servers(potentially different versions) and slightly different resource paths depending on configuration.
For e.g. http://server1/myRest or http://server2/theRest etc.

We would like to be able to run our test suites and test cases against those different endpoint/resource combinations. So far, the only way we found to change the endpoint is at test case level using the Test Case editor and to change the resource/method at test step level.

Clearly, it's not an option to duplicate all test cases / test suites for each endpoint / resource path combination or to create projects for that.

Is there a simple way to achieve that using SOAPUI (free)?

like image 659
Julien Charon Avatar asked Jan 25 '16 09:01

Julien Charon


1 Answers

We were able to find a solution to our problems, the key is to use project level properties.

Endpoint

Basically, there are 2 ways for doing this.

With properties

  1. Open the project view for your project and add a property named ServiceEndpoint (or any other name you want to use). Value is the host name, e.g. server1:8090
  2. Open the service viewer for your service. On Tab Service Endpoints, add an endpoint http://${#Project#ServiceEndpoint}
  3. Still in the service viewer, click the Assign button, select to which requests (all requests, test requests, both ...) you want to assign the endpoint to.

Now you only need to modify the project level property if you want to use another endpoint

Without properties

  1. Use the service viewer to add the endpoints you need to use (see point 2 above)
  2. Assign the endpoint you want to use (see point 3 above)

Resource path

  1. Use the project view to define a property ResourcePath
  2. Add a new resource, define /{ServicePath} as the resource path
  3. Open the resource in the resource viewer. You will see that a parameter with name ServicePath with stlye TEMPLATE was added. Give it the value ${#Project#ResourcePath}
  4. Use this resource in your test suites / test cases

Now you only need to modify the project level property to change the resource path.

You can also define multiple path components, e.g. /{serviceName}/{methodName} or something similar. Of course you would need 2 variables for that.

Note: if the value of your path property contains a /, you will need to edit the SOAP UI HTTP Settings in the preferences and check the Pre-Encoded Endpoints checkbox, otherwise it won't work because the / will be URL encoded

like image 134
Julien Charon Avatar answered Sep 28 '22 00:09

Julien Charon