当前位置: 首页 > 工具软件 > soapUI > 使用案例 >

soapui教程

楚灿
2023-12-01

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()
 类似资料: