如何使用groovy更改端点url
我在测试套件级别使用了下面的如何使用groovy更改端点url,groovy,soapui,Groovy,Soapui,我在测试套件级别使用了下面的 result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT']); 在运行测试套件时,我使用下拉菜单选择一个属性。现在,在选择属性之后,它必须为所有测试用例设置端点URL并执行运行 谢谢每个testStep都有一个endpoint属性,它是为此testStep调用的端点url。如果您想更改testS
result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT']);
在运行测试套件时,我使用下拉菜单选择一个属性。现在,在选择属性之后,它必须为所有测试用例设置端点URL并执行运行
谢谢每个
testStep
都有一个endpoint
属性,它是为此testStep
调用的端点url。如果您想更改testSuite
中每个testCase
中每个testStep
的所有端点,您可以在每个端点之间循环更改此属性。为此,您可以使用groovytestStep
和以下代码:
def result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
def testcases = testRunner.testCase.testSuite.getTestCaseList()
// for all testCases in your test suite...
testcases.each { testcase ->
// for all testStep inside testCase...
def teststeps = testcase.getTestStepList()
teststeps.each { teststep ->
teststep.setPropertyValue('endpoint','http://yourUrl')
}
}
def result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
def testcases = testSuite.getTestCaseList()
testcases.each { testcase ->
def teststeps = testcase.getTestStepList()
teststeps.each { teststep ->
teststep.setPropertyValue('endpoint','http://yourUrl')
}
}
如果您喜欢在testSuite
上的Setup脚本中执行相同的操作,您必须稍微更改代码,因为上下文中没有testrunner
(您可以直接使用testSuite
var)。因此,如果要将代码放在设置脚本
中,而不是放在groovytestStep
中,可以使用以下代码:
def result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
def testcases = testRunner.testCase.testSuite.getTestCaseList()
// for all testCases in your test suite...
testcases.each { testcase ->
// for all testStep inside testCase...
def teststeps = testcase.getTestStepList()
teststeps.each { teststep ->
teststep.setPropertyValue('endpoint','http://yourUrl')
}
}
def result = com.eviware.soapui.support.UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
def testcases = testSuite.getTestCaseList()
testcases.each { testcase ->
def teststeps = testcase.getTestStepList()
teststeps.each { teststep ->
teststep.setPropertyValue('endpoint','http://yourUrl')
}
}
希望这有帮助,您还可以设置所有端点
属性,以及用户名
和密码
,如下所示:
- 打开界面查看器(右键单击界面)
- 转到“服务端点”选项卡
- 选择要用于测试会话的端点
- 单击“分配”,然后选择要分配此端点的位置
快乐测试 您的问题不清楚-您在问什么?我试图做的是使用groovy更改SOAP UI中的端点URL。我想使用“提示”对话框进行更改并选择属性值。选择该属性时,测试套件应运行。