SoapUI 5.4.0 query on setup script :dynamic endpoint url
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SoapUI 5.4.0 query on setup script :dynamic endpoint url
Hi i want to place the endpoint url dynamically on the basis of test case name through setup script in SOAPUI 5.4.0 version. If I am having three test cases in a test suite ,Testcase-A and Testcase-b should run at one url and Testcase-C should run at different url ,I am using below code but its replacing all endpoint urls in all test cases. ----------------------- def result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['UAT_API','IT2','IT3','UAT1','UAT2','UAT3']) def testcases = testSuite.getTestCaseList() if(result == 'UAT1'){ testcases.each { testcase -> def teststeps = testcase.getTestStepList() teststeps.each { teststep -> teststep.setPropertyValue('endpoint','') } } }else if(result == 'UAT2'){ testcases.each { testcase -> def teststeps = testcase.getTestStepList() teststeps.each { teststep -> teststep.setPropertyValue('endpoint','') } } }else if(result == 'UAT3'){ testcases.each { testcase -> def teststeps = testcase.getTestStepList() teststeps.each { teststep -> teststep.setPropertyValue('endpoint','') } } }else if(result == 'UAT_API'){ testcases.each { testcase -> def teststeps = testcase.getTestStepList() teststeps.each { teststep -> teststep.setPropertyValue('endpoint','https://alpha-api.com') } } }else if(result == 'IT2'){ testcases.each { testcase -> def teststeps = testcase.getTestStepList() teststeps.each { teststep -> teststep.setPropertyValue('endpoint','https://it2-webservices.com:1') } } }else if(result == 'IT3'){ testcases.each { testcase -> def teststeps = testcase.getTestStepList() teststeps.each { teststep -> teststep.setPropertyValue('endpoint','') } } } ------------------------------- What is the solution for this.Can anyone help on this
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this:
Map endpoints = [ 'UAT_API': [
"http://foo",
"http://bar"
], 'IT2': [
"http://foo2",
"http://bar2"
], //... ] def result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['UAT_API','IT2','IT3','UAT1','UAT2','UAT3']) Closure setTestCaseEndpoints = { tc -> def steps = tc.getTestStepList() steps[0].setPropertyValue("endpoint", endpoints[result][0]) steps[1].setPropertyValue("endpoint", endpoints[result][0]) steps[2].setPropertyValue("endpoint", endpoints[result][1]) } testSuite.getTestCaseList().each(setTestCaseEndpoints)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Getting below exception:
Cannot invoke method setPropertyValue() on null object
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I misread. You were wanting to set the endpoint on each testStep in a testcase.
Try:
Map endpoints = [ 'UAT_API': [ "http://foo", "http://bar" ], 'IT2': [ "http://foo2", "http://bar2" ], //... ] def result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['UAT_API','IT2','IT3','UAT1','UAT2','UAT3']) def cases = testSuite.getTestCaseList() cases[0].getTestStepList().each { step -> step.setPropertyValue("endpoint", endpoints[result][0]) } cases[1].getTestStepList().each { step -> step.setPropertyValue("endpoint", endpoints[result][0]) } cases[2].getTestStepList().each { step -> step.setPropertyValue("endpoint", endpoints[result][1]) }
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankyou is working ..
Could you please tell if I select one env ex:UAT_API endpoint url .is there any way to disable few test cases and again enable those test cases if i use other endpoint url ex:IT2
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got the solution for disable /enable ...Thanks a lot for your help.
One query here we how we can use by test case name and by test case step instead of using ".each" here
cases[0].getTestStepList().each { step -> step.setPropertyValue("endpoint", endpoints[result][0]) }
