cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Another Test Step Groovy script into another Test Case using Groovy.

Highlighted
Contributor

Calling Another Test Step Groovy script into another Test Case using Groovy.

Hi Team

 

I have a scenario I need to call a Groovy script test script into another Groovy script. Both are in the different test cases.

 

Please find the attached screen shot.

 

Capture.JPG

6 REPLIES 6
Highlighted
Contributor

Re: Calling Another Test Step Groovy script into another Test Case using Groovy.

Below are the Script I have used, It is executing but not updating the endpoints.

 

def stage1 = testRunner.testCase.testSuite.getPropertyValue( "STAGE1" );
def testcases = testRunner.getTestCase()

//Environment Selection Staging 1
testcases.each {
testcase ->
def teststeps = testcase.getTestStepList()
teststeps.each { teststep ->
teststep.setPropertyValue('Endpoint',stage1)
}
}

def testing = testRunner.testCase.testSuite.project.getTestSuiteByName("Logging Availability_STAGE").getTestCaseByName("INFO_ESBLOGS_STAGE").getTestStepByName("Staging1")
testing.run(testRunner, context)

 

Highlighted
Super Contributor

Re: Calling Another Test Step Groovy script into another Test Case using Groovy.

I'm not sure how you can run individual test steps, but can I suggest that if you want to create reusable functionality you create you create it as TestCases, this way you can use the provided Run TestCase Test Step functionality. I go into a lot more detail of creating reusable functionality in the following two posts;

 

https://community.smartbear.com/t5/SoapUI-Pro/Need-help-to-modularizing-tests-using-soapui-pro/m-p/1...

https://community.smartbear.com/t5/SoapUI-Pro/How-to-loop-Test-Suites-or-Test-Cases/m-p/144035

 

Alternatively you if it is just Groovy code you want to run from multiple locations, you can move this into a Groovy script library, see the following documentation page:

 

https://support.smartbear.com/readyapi/docs/testing/scripts/library.html

Highlighted
Community Hero

Re: Calling Another Test Step Groovy script into another Test Case using Groovy.

In my view, the better way would be to create a library to achieve so. Have a class and methods and call them in groovy script in order to achieve re-usability.

Please see below link to see how to do it:
http://rupertanderson.com/blog/1-how-to-develop-add-and-use-a-custom-groovy-library-in-soapui/

 

Otherway, there is no need to call a groovy script in another script as you can have the same script here it self. If you want to achive re-usability, then above is the right way. And you do not have to create the other groovy script step itself.



Regards,
Rao.
Highlighted
Community Manager

Re: Calling Another Test Step Groovy script into another Test Case using Groovy.

@maddenapally, did you find the solution you want to use?

---------
Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Contributor

Re: Calling Another Test Step Groovy script into another Test Case using Groovy.

Yes, Thanks

 

Regards,

Karthik

Highlighted
Community Manager

Re: Calling Another Test Step Groovy script into another Test Case using Groovy.

That's great to hear. Do you mind sharing it with us? This may help other users who will face a similar question.

---------
Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Filtering data retrieved from a DataSource

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors