soapUI 使用Property

时间:2023-03-09 09:47:19
soapUI 使用Property

DRY 原则是一个比较普适的东西,在使用soapUI测试的时候,为了make life easy,我们必须要使用Property来集中化一些设置。

比如说从dev->test->uat 的切换,我们有成百上千个test case,所有的endpoints 需要在不同的环境切换过程中快捷的切换。
比如说一些验证信息,账号密码类的,不至于搞得到处都是,万一改个密码就是要死人的。
比如说登陆后的session id.可以在不同的请求之间共享。

定义Properties

soapUI的各个级别都可以自定义Property.包括Project, TestSuite ,TestCase 级别。

soapUI 使用Property

脚本中使用properties

// get username property from TestSuite
def username = testRunner.testCase.testSuite.getPropertyValue( "Username" )

当然前提是你已经定义了该property

soapUI 使用Property

Example - 集中管理Endpoint

1 定义TestSuit 级别的Properties

soapUI 使用Property

2 设置

soapUI 使用Property

3 使用

soapUI 使用Property