How to parameterise a value in Soap request

非 Y 不嫁゛ 提交于 2019-12-11 03:30:43

问题


I am new to soapUI so getting to grips with the tool, so any help would be much appreciated..

We have two environment configured (DEV, Staging) each with different end points which enables me to run my testsuite on either of the two environment.

As part of request in one of my testcases, I need to supply an 'accountID' however this accountID is different for each Environment therefore I would like to know how and where I can add the logic that would enable me to chose different account ID depending on the envionment I am selecting at the project level?

Please see attached image of the accountID filed that I am currently having to manually change depending on which server I am running the test on...

If solution is groovy script based , then could you please provide what the script should look like because my scripting skill at this point isn't that great..

Cheers

Shan


回答1:


Add a custom property to project. You can redefine value of this property in different environments. In test case you can access this property as ${#Project#property_name}




回答2:


At times there can be test case specific properties, similarly property for specific applicable and may be really applicable/make sense to define at project level.

So the same properties can be accessed in the test request steps as below similar to project property

  • Test Case Level property - ${#TestCase#TEST_CASE_PROPERTY_NAME}
  • Test Suite Level property - ${#TestSuite#TEST_SUITE_PROPERTY_NAME}
  • Project Level property - ${#Project#PROJECT_PROPERTY_NAME}

In case, the same properties needs to be access in groovy scripts in below way:

def propValueTC = testRunner.testCase.getPropertyValue('TEST_CASE_PROPERTY_NAME') 
def propValueTS = testRunner.testCase.testSuite.getPropertyValue('TEST_SUITE_PROPERTY_NAME') 
def propValueP = testRunner.testCase.testSuite.project.getPropertyValue('PROJECT_PROPERTY_NAME') 
//or
def propValueTC = context.expand('${#TestCase#TEST_CASE_PROPERTY_NAME}')
def propValueTS = context.expand('${#TestSuite#TEST_SUITE_PROPERTY_NAME}')
def propValueP = context.expand('${#Project#PROJECT_PROPERTY_NAME}')

Similarly one can use setPropertyValue('property','value') as counter part to get



来源:https://stackoverflow.com/questions/16715491/how-to-parameterise-a-value-in-soap-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!