---
title: "SoapUI Rest测试 随机数 XPATH"
author: "asyty"
date: "2011-10-25T08:43:09Z"
tags: []
categories: ["Web前端"]
slug: "soapui-rest-xpath"
draft: false
lastmod: "2011-10-25T08:43:52Z"
id: 1211822
url: "https://asyty.iteye.com/blog/1211822"
---

Soapui中使用内置方法随机生成整数： ${=(int)Math.random()\*2000}

在对xml进行assertion验证时，如果简单的xml没有namespace，例如

 

```
<xml>
<a>
<b>ccc</b>
</a>
</xml>
```

 

 

可使用XPATH //\*:xml\[1]/\*:a\[1]/\*:b\[1]/text() 访问到ccc

由于涉及到项目资料，就不贴图了，具体的其他资料请在网上搜索

 

SoapUI Rest测试入门

[http://www.soapui.org/REST-Testing/getting-started.html](http://www.soapui.org/REST-Testing/getting-started.html)

Rest 测试的资源参数说明

[http://www.soapui.org/REST-Testing/understanding-rest-parameters.html](http://www.soapui.org/REST-Testing/understanding-rest-parameters.html)

Soapui通过assertion对response验证

[http://www.soapui.org/Functional-Testing/getting-started-with-assertions.html](http://www.soapui.org/Functional-Testing/getting-started-with-assertions.html)

XPath验证

[http://www.soapui.org/Functional-Testing/xpath-and-xquery-assertions.html](http://www.soapui.org/Functional-Testing/xpath-and-xquery-assertions.html)

Demo参照[http://www.soapui.org/REST-Testing/getting-started.html](http://www.soapui.org/REST-Testing/getting-started.html)