Ask a Question

Clone Test Step into Multiple Test Cases Using Groovy

socaltester
Contributor

Clone Test Step into Multiple Test Cases Using Groovy

I have a Test Step that I need to clone into all the Test Cases I have within all the Test Suites. Would the following script work when ran against each Test Suite individually:

def slaveTestStep = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite").getTestCaseByName("Name")
testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite").get TestCaseByName("Name").cloneTestStepByName(slaveTestStep,"NewName")

 
Tags (0)
Add tags

 

8 REPLIES 8
richie
Community Hero

Re: Clone Test Step into Multiple Test Cases Using Groovy

Hey @socaltester,

Have you tried the script? Easiest way to find out if it works is to try it on a small dummy testsuite surely?

Then if it doesnt work you can post any error response you get to assist the diagnosis?

Just a suggestion....whenever im passing anything to qnt variables, u always add logging to ensure its working and to assist diagnosis if it doesnt

Ta

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
socaltester
Contributor

Re: Clone Test Step into Multiple Test Cases Using Groovy

Yes. Posting the results will have to wait until Monday.
socaltester
Contributor

Re: Clone Test Step into Multiple Test Cases Using Groovy

Example Result:

def slaveTestStep = testRunner.testCase.testSuite.project.getTestSuiteByName("AdminTestSuite").getTestCaseByName("Authenticate")
testRunner.testCase.testSuite.project.getTestSuiteByName("AdminTestSuite").getTestCaseByName("AppBundles(addBundle)").cloneTestStepByName(slaveTestStep,"Authenticate")Tags (0) authentication

Exception thrown

groovy.lang.MissingPropertyException: No such property: testRunner for class: cloneAuthenticateStep
at cloneAuthenticateStep.run(cloneAuthenticateStep.groovy:1)

 

 

Note: I'm attempting to use the GroovyConsole tool withing SoapUI Pro

 

I'm hoping this might help: https://community.smartbear.com/t5/SoapUI-Pro/SoapUI3-5-No-such-property-testRunner-for-clases-Scrip...

 

"...the assertion script does not have access to the testRunner variable..."

 

def testCase = messageExchange.modelItem.testCase

def ResponseMessage = testCase.testSteps["Step1"].testRequest.response.contentAsString

log.debug 'response is :::: ' + ResponseMessage

socaltester
Contributor

Re: Clone Test Step into Multiple Test Cases Using Groovy

Added def testCase - messageExchange.modeItem.testCase

def testCase = messageExchange.modelItem.testCase
def slaveTestStep = testRunner.testCase.testSuite.project.getTestSuiteByName("AdminTestSuite").getTestCaseByName("Authenticate")
testRunner.testCase.testSuite.project.getTestSuiteByName("AdminTestSuite").getTestCaseByName("AppBundles(addBundle)").cloneTestStepByName(slaveTestStep,"Authenticate")Tags (0) authentication

Now this is the Exception:

Exception thrown

groovy.lang.MissingPropertyException: No such property: messageExchange for class: cloneAuthenticateStep

	at cloneAuthenticateStep.run(cloneAuthenticateStep.groovy:1)
richie
Community Hero

Re: Clone Test Step into Multiple Test Cases Using Groovy

Hey @socaltester,

Is this a groovyscript or script assertion?

I know testrunner isnt available in script assertions so you need to use messageExchange instead.

It looks like youve mixed and matched...when you define the testcase variable try using testrunner instead (assuming this is groovy step) of messageExchange.

Nice one,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
socaltester
Contributor

Re: Clone Test Step into Multiple Test Cases Using Groovy

Thank you, Rich. This is to be a Groovy Script. I'll give your recommendation a shot.

sonya_m
Community Manager

Re: Clone Test Step into Multiple Test Cases Using Groovy

Thank you richie. 

@socaltester , please keep us informed of your progress with solving this one. Thanks. 


Sonya Mihaljova
Community and Education Specialist

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

Re: Clone Test Step into Multiple Test Cases Using Groovy

Hi @socaltester,

Was the original issue resolved? Please let us know if you still need assistance.

 

 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: