Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
15 years ago

creating groovy teststep with code via groovy

Hello,
How can I create a testsuite/testcase/groovy teststep via another groovy step.

For example:
I have a groovy step in testSuite1-->Testcase1-->'groovy step'
I need this groovy step to do the following

1. Create testsuite2
2. Create testcase2 (inside testsuite2)
3. Create 'groovy teststep' in testsuite2-->testcase2 with the following code
-- log.info('hello world')
4. Save project.

Thanks

Ali
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    import com.eviware.soapui.impl.wsdl.teststeps.registry.GroovyScriptStepFactory
    suite = context.testCase.testSuite.project.addNewTestSuite("ali")
    tc = suite.addNewTestCase("test case ali")
    gs = tc.addTestStep( GroovyScriptStepFactory.GROOVY_TYPE, "ali's GroovyScript" )
    gs.properties["script"].value = 'log.info(\'hello world\')'
    context.testCase.testSuite.project.save()



    Try this, and let me know does it helps,
    robert
    • Davnm's avatar
      Davnm
      Member

      Thanks for the example.

       

      What I am trying to achieve is to dynamically create a SOAP UI request in its own test suite using groovy scripting. very similar to the example below but instead of GroovyScriptStepFactory, I need a SOAPScriptStepFactory if you know what I mean.

  • nmrao's avatar
    nmrao
    Champion Level 3
    Haven't found any value by doing so.
    Because, in order to achieve whatever you are talking via groovy script, it is required to do you need to do the same.

    what is your use case?

    Is not it simple to create a test suite -> test case with dynamic steps in your case as needed.