BruceyBandit BruceyBandit - 1 year ago 110
Groovy Question

How to retreive endpoint of a service

i want to add my project's endpoint in the project tear down script. What is the syntax in order to get the endpoint for all requests and test requests as the user will assign their endpoint via all requests and test requests before running the project?

i seen an example using test step but i don't want to retrieve it via the test step route:

testRunner.testCase.getTestStepByName("dd").getHttpRequest().getEndpoint();


The tear down script use either , log, context, runner nd project variables.

Thanks

Rao Rao
Answer Source

Based on the information updated in the question, it looks like you have to access the endpoint in the TearDown Script of the project.

It also appears that you would need to execute the same set of tests against different base url of the endpoint and domain. Not sure even you might need to use the credentials accordingly.

Considering the above, it would be easy to project level properties.

Here you would go:

  • Create a project level custom property for base url, say BASE_URL as property name and value as http://10.0.0.1:8008. Of course, change it with actual value as needed with respect to the tests to be executed.
  • Similarly create another project level property for domain, say DOMAIN_NAME and provide its value according the test.
  • Double click on service / interface, click on Service Endpoints tab.
  • Remove all the existing values.
  • Add a new endpoint by clicking + icon.
  • Add ${#Project#BASE_URL} as endpoint and ${#Project#DOMAIN_NAME} as domain values
  • If required, you use the same approach for the credentials.
  • Now click on Assign button there and choose All requests and Tests option from the dropdown.
  • Similarly, do the same if you have multiple services / interfaces.

How to access the above values in TearDown Script?

log.info "Endpoint : ${project.getPropertyValue('BASE_URL')}"
log.info "Domain : ${project.getPropertyValue('DOMAIN_NAME')}"

When you want to change domain or base url, just change the values of the respective project properties before you run execute the tests against different servers / environments.

EDIT:

The values for the endpoint or domain can passed dynamically (without even changing value saved in the project) from command line using SOAPUI_HOME/bin/testrunner utility while executing the tests. For more details, refer documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download