如何更改SoapUI

时间:2015-09-10 11:16:05

标签: rest automation soapui web-api-testing

我们正在使用SoapUI免费版自动化Rest API。

这里我们想要处理服务URL,即截至目前,我们有3个测试环境:QA,UAT,Pre-Prod。环境之间的区别是基本URL。终点将是相同的。

然而,很少有端点可能也会发生变化。因此,我们使用其基本URL和端点在UAT中创建了自动化脚本和套件。

我们的问题是:假设我想在QA环境中运行我的套件,那么基本URL和一些端点都会发生变化。

在这种情况下,如何在属性文件等集中位置提供基本URL?这样我们就可以以一种强大的方式在所有环境中运行套件。

有人能帮助我们吗?

1 个答案:

答案 0 :(得分:0)

您可以在测试套件级别编写设置脚本以维护端点URL。

我做过类似的事情

def testcases = testSuite.getTestCaseList()
def endpoint = context.expand( '${#Project#endpoint}' )
def port = context.expand( '${#Project#port}' )

testcases.each { testcase ->
    def teststeps = testcase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class ) 

    teststeps.each { teststep ->
        teststep.setPropertyValue('endpoint','https://' + endpoint +'-accountservice.com:'+port+'/accountservices')
    }
}

您可以在测试项目开始时根据测试环境定义端点,端口。

由于