krogold
6 years agoRegular Contributor
how to get endpoint from default environment ?
Hello, I'm able to get endpoint from my project's active environment, using the following : def env = testRunner.testCase.testSuite.project.activeEnvironment
log.info("Active Environment: " + env....
- 6 years ago
Hi krogold,
You cannot get an endpoint of the default environment because there is no common endpoint. You can configure a new endpoint for every test step even if they were created based on the same service. Please see my sample video: https://1drv.ms/u/s!AnCx6DcSb33_nXgxTD4Kvm33FpGQ
In case of the Default environment, you may want to get a service endpoint or an endpoint of a particular test step. Here is the script to get the service endpoint:
def project = context.getTestCase().getTestSuite().getProject(); def endpoint = project.getInterfaceAt(0).getEndpoints().toString() log.info("Service endpoint: " + endpoint)
If you want to do this on one Groovy test step, you can use the following script:
def env = testRunner.testCase.testSuite.project.activeEnvironment log.info("Active Environment: " + env.name) if (env.name!="Default environment") { rest = testRunner.testCase.testSuite.project.activeEnvironment.getRestServiceAt(0) config = rest.getEndpoint().config envEndpoint = new XmlSlurper().parseText(config.toString()) log.info("Environment endpoint: " + envEndpoint) } else { def project = context.getTestCase().getTestSuite().getProject(); def endpoint = project.getInterfaceAt(0).getEndpoints().toString() log.info("Service endpoint: " + endpoint) }