Ask a Question

creating groovy teststep with code via groovy

alibaba82
Super Contributor

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
3 REPLIES 3

Re: creating groovy teststep with code via groovy

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


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Davnm
Member

Re: creating groovy teststep with code via groovy

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
Community Hero

Re: creating groovy teststep with code via groovy

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.


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: