[SoapUI] Property Expansion in soapUI
1. Property Expansion in soapUI
SoapUI provides a common syntax to dynamically insert ("expand") property values during processing. The syntax is as follows:
${[scope]propertyName[#xpath-expression]}
where scope can be one of the following literal values:
- #Project# - references a Project property(Reference properties across a particular SoapUI project)
- #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. Found in File>Preferences>Global Properties tab. Reference properties across all projects
- #System# - references a system property. Found in Help>System properties.
- #Env# - references an environment variable
- [TestStep name]# - references a TestStep property
Many of the scopes will of course only work if they are available, i.e. you can not use the #MockService# scope within a TestCase script since there is no containing MockService to access.
If no scope is specified, the property is resolved as follows:
- Check the current context (for example the TestRunContext) for a property with the matching name
- Check for a matching global property
- Check for a matching system property
If the property expansion further includes an XPath expression, this will be used to select the corresponding value from the referenced property value (which must contain XML), for example the following example could "extract" the author value from a preceding response with:
${Search Request#Response#//ns1:Item[1]/n1:Author[1]/text()}
Which would first get the "Response" property of the "Search Request" step and then select the value of the first Items' first Author element. Note that the namespace prefix must match those used in the response message, otherwise the expansion will fail.
As you can see, there is no way to access properties "outside" scope, i.e. you can not access a property in another TestCase from within a TestStep. This is a deliberate restriction aiming to reduce dependencies between items. If you need to transfer values between (for example) two TestCases you should use the containing common TestSuite or Project as an intermediary; the first TestCase transfers to the common parent using a Property-Transfer or Groovy script, the second reads from the same parent. In this way, there is no direct dependency between the two TestCases and the value supplied by the first TestCase can be supplied by any other source (TestCase, Script, etc...) or statically.
Property Transfers are a more tedious way of accomplishing the same functionality as with property-expansion. On the other hand, property transfers provide the possibility to transfer complex content between request, response messages. Also, the result of a Property Transfer is visible directly in the corresponding request, response editors.
Property-Expansion is supported wherever a value is to be specified, if you find a place where it doesn't seem to work like you want please let us know!
2. Dynamic Properties
SoapUI 2.5 introduced the possibility to write groovy scripts directly inside a PropertyExpansion; prefix the content with a '=' and the remaining content up to the closing brace will be evaluated as a script and its result will be inserted. For example
${=(int)(Math.random()*1000)}
will be replaced with a random number between 0 and 999 every time it is evaluated.
Of course this applies to all places where property-expansions can be used; requests, property values, file names, endpoints, etc.. etc..
Depending on the context of the expansion, relevant variables will be available for accessing the soapUI object model. For example in a request message or parameter, the containing Request object will be available through the "request" variable, allowing you to (for example) insert its name in your request
...
${=request.name}
...
or if you want the name of the project just navigate up the soapUI ModelItem tree:
...
${=request.operation.interface.project.name}
...
If you want to provide a current formatted timestamp:
...
${=import java.text.SimpleDateFormat ; new SimpleDateFormat("YYYY-MM-DDT00:00:00").format(new Date())}
...
The following variables are (almost) always available in these scripts:
- log : a log4j Logger logging to the groovy log window
- modelItem : the current modelItem (for example a Request, MockResponse, etc..).
- context : the current run-context (for example when running a TestCase or MockService)
For soapUI Pro users, the global script library is available just as in any other script, allowing you to call into objects/methods defined there for reuse. One current limitation is that although scripts can be multiple lines, they can not contain nested braces (yet).. as always there is room for improvement!
3. 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"
[SoapUI] Property Expansion in soapUI的更多相关文章
- SoapUI Property
1. Test Suite(Case) Property 选择Test Suite(Case),switch to Custom properties 在request中的引用方式: ${[scope ...
- [SoapUI] 通过Groovy获取SoapUI当前Project所在的目录
import com.eviware.soapui.support.GroovyUtils def groovyUtils = new GroovyUtils( context ) def proje ...
- [SoapUI] SOAP UI-Groovy Useful Commands
Hi All, I have posted the SOAPUI and Groovy useful commands that may help you in your testing. Below ...
- SoapUI Properties的使用
Link:http://testautomationnoob.blogspot.com/2012/10/soapui-properties-and-property-related.html soap ...
- soapUI学习文档(转载)
soapUI 学习文档不是前言的前言记得一个搞开发的同事突然跑来叫能不能做个WebService 性能测试,当时我就凌乱了,不淡定啊,因为我是做测试的,以前连WebService 是什么不知道,毕竟咱 ...
- SoapUI调用webservice实现的两种方式
SoapUI用来做测试,已经是很多人做过的事情了,而且网上教程也很多.不过还是写下来,对比webservice协议与http协议脚本编写的不同. 首先测接口得有一个服务,刚好笔者所在项目做ESB集成. ...
- IGS_学习笔记08_IREP通过soapUI测试客户化Web Service调用(案例)
20150819 Created By BaoXinjian
- soapUI通过groovy脚本设置超时时间
import com.eviware.soapui.SoapUI import com.eviware.soapui.settings.HttpSettings import com.eviware. ...
- 根据wsdl文件用soapUi快速创建webService服务(有图有真相)
最近公司业务上使用webservice 频繁.由于之前都是自己搭建webservice 自己定义提供给别人服务,现在则相反需求都是根据人家提供的wsdl 文件来生成 我们平台需要提供的接口.刚开始不知 ...
随机推荐
- 微擎框架下拉分页(使用js模板引擎)
1.需要分页的页面,引入一下文件 <script language="javascript" src="\addons\{$_GPC['m']}\template\ ...
- Eclipse git 冲突合并
Eclipse有一个git的插件叫EGit,用于实现本地代码和远程代码对比.合并以及提交.但是在本地代码和远程代码有冲突的时候,EGit的处理方案还是有点复杂.今天就彻底把这些步骤给理清楚,并公开让一 ...
- JMeter学习(二十一)关联(转载)
转载自 http://www.cnblogs.com/yangxia-test 话说LoadRunner有的一些功能,比如:参数化.检查点.集合点.关联,Jmeter也都有这些功能,只是功能可能稍弱一 ...
- SQL Server中row_number的用法
ROW_NUMBER()函数将针对SELECT语句返回的每一行,从1开始编号,赋予其连续的编号.在查询时应用了一个排序标准后,只有通过编号才能够保证其顺序是一致的,当使用ROW_NUMBER函数时,也 ...
- 这篇说的是Unity Input 输入控制器
关于Unity3D是什么.我就不多做解释了.由于工作原因,该系列原创教程不定期更新.每月必然有更新.谢谢各位 Unity Input---输入控制管理器: Edit->Project Setti ...
- http://ctf.bugku.com/challenges#Easy_Re
今天做一道逆向题,开心,见证了自己汇编的用途. 首先看它是否加壳? 1.加壳检测 是vc编程的,没有加壳,可以愉快地分析了. 2.分析程序,找到flag. 首先运行一下子程序, ...
- ES3之变量提升 ( hoisting )
JavaScript引擎在预编译时,会将声明(函数声明.变量声明)自动提升至函数或全局代码的顶部.但是赋值不会提升. Because variable declarations (and declar ...
- 支付宝小程序开发之与微信小程序不同的地方
前言: 本文仅汇总微信小程序移植支付宝小程序过程中遇到的一些不同的地方,详细请参考官方开发文档. 网络请求: 对于网络请求,基本上改动不大,也就支付宝小程序没有responseType属性及响应码字段 ...
- ssh免密登陆权限问题
问题: 添加了authorized_keys还是不能免密登陆. 思路: 检查端口是否开放,是否允许root用户登录,尝试重启ssh服务... 最有可能的还是权限问题,出现Permission deni ...
- C++ 智能指针shared_ptr的实现
#include <memory> #include <iostream> using namespace std; template<typename T> cl ...