1. soapUi系列
1.1 设置参数值:setPropertyValue
SoapUI允许在项目的各个层次中定义变量,常用的层次包括: Project,TestSuite,TestCase,Global等。具体如下:
a. 设置 project level property
//set to project level property 下面两种写法都可以
testRunner.testCase.testSuite.project.setPropertyValue(“Name”, “propValue”);
testRunner.testCase.getTestSuite().getProject().setPropertyValue(“Name”, “propValue”);; //项目对象
b. 设置 testSuite level property
//set to testSuite level property
testRunner.testCase.testSuite.setPropertyValue(“Name”,“testSuiteValue”);
testRunner.testCase.getTestSuite().setPropertyValue(“Name”,“testSuiteValue”);
c. 设置 testCase level property
//set to testCase level property
testRunner.testCase.setPropertyValue(“Name”,“testCaseValue”);
d. 设置 testStep level property
//set to testStep level property
testRunner.testCase.testSteps[‘Groovy’].setPropertyValue(“Name”,“testSuiteValue”);
testRunner.testCase.getTestStepByName(“Groovy”).setPropertyValue(“Name”,“testSuiteValue”);
1.2 获取参数值:getPropertyValue
注意,如果在 Groovy Script中获取参数的话,可以用以下方法:def time_num= context.expand (‘${#Project#hospitalId}’) //##号内为定义哪个级别的属性变量,后面为属性名,如下