Forum Discussion

sjakovac's avatar
Occasional Contributor
3 years ago

Accessing environment from Groovy script test step

I want to get hold of the environment inside groovy script in Groovy test step. This solution does not work in ReadyAPI 3.9.1.

If there is another way of getting projects APIs and their endpoints in the current environment, that would help also. (KafkaEndpoint to be precise)

2 Replies

  • nmrao's avatar
    Champion Level 3
    would you please show what you have tried? and the available environments?
    • sjakovac's avatar
      Occasional Contributor

      I can get an active environment using 

      def env = context.testCase.testSuite.project.getActiveEnvironment()

      But I can not access Kafka service /endpoint like it's suggested for REST/SOAP service.

      For example, after the previous line none of the following works:

      def kafkaService = env.getService('Name of kafka service', com.eviware.soapui.config.ServiceConfig.Type.Enum.forString("KAFKA"))
      def kafkaService = env.getKafkaServiceAt(0)

      Autocomplete/code-suggestion is not of any help so I don't know what else is available through env object. When I run following to try to discover something:

      env.getProperties().each { name, val -> + ': ' + val)

      Output is:


      My environment setup is: