soapui教程

soapui加载properties文件的方法:

For example, create a properties-file named "properties.txt" containing

test.a.property=hello!

in the soapUI bin folder. Modify the java arguments in the soapUI.batbat/.sh file to be

set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx256m -Dsoapui.properties=properties.txt

Add the following Property-Expansion to a TestRequest, Endpoint, etc...

${test.a.property}

When expanded, the specified properties file will be loaded as shown in the soapUI log:

01:20:05,234 INFO [PropertyExpansionRequestFilter] Loaded 52 properties from [C:\workspace\core\project.properties]

Property Expansion in soapUI



${[scope]propertyName[#xpath-expression]}

where scope can be one of the following literal values:

  • #Project# - references a Project property
  • #TestSuite# - references a TestSuite property in the containing TestSuite
  • #TestCase# - references a TestCase property in the containing TestCase
  • #MockService# - references a MockService property in the containing MockService
  • #Global# - references a global property (optional)
  • #System# - references a system property
  • #Env# - references a environment variable
  • [TestStep name]# - references a TestStep property within the current TestCase

Dynamic Properties

${=(int)(Math.random()*1000)}

Nested Properties

soapUI supports both nested and recursive property-expansion (be careful!), for example:

test = "value" testexp = "${test}"

-> "${testexp}" evaluates to "value"

testexp = "value" exp = "${exp}"

-> "${test${exp}}" evaluates to "value"

testxml = "hello" testxpath = "//value[@id=${id}]/text()" id = "123"

-> "${#testxml#${testxpath}}" evaluates to "hello

Groovy Script Library

Specify which folder to use in the soapUI Pro Preferences tab (default is /scripts).

Remember that the script files must be valid classes, not just arbitrary scripts. The following example is included with the soapUI Pro distribution, it consists of the following Greet.groovy file that is located in a soapui\demo folder under the default scripts folder:

01. package soapui.demo
02.  
03. class Greet
04. {
05. def name
06. def log
07.  
08. Greet(who, log)
09. {
10. name = who;
11. this.log = log
12. }
13.  
14. def salute() { log.info "Hello $name" }
15.  
16. def static salute( who, log ) { log.info "Hello again $who!" }
17. }
def greet = new soapui.demo.Greet( "Ole", log )
greet.salute()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值