Ask a Question

SoapUI 5.4.0 query on setup script :dynamic endpoint url

SOLVED
kric
New Contributor

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

5 REPLIES 5
JHunt
Community Hero

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)

 

kric
New Contributor

Getting below exception:

Cannot invoke method setPropertyValue() on null object

JHunt
Community Hero

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]) }
kric
New Contributor

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

kric
New Contributor

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]) }

cancel
Showing results for 
Search instead for 
Did you mean: