SoapUI中Groovy的实用方法
1.依照上次结果判断下步是否执行:
import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus
myTestStepResult = testRunner.runTestStepByName("Verify Step one")
myStatus = myTestStepResult.getStatus(
if( myStatus ==TestStepStatus.OK)
** execute the next testRunnerStep **
2.获取到Assert的结果:
def iAssertionName = assertionNameList[j]
def iAssertionStatus = testStep.getAssertionAt(j).getStatus().toString()
def tstep = testStep.getName()
def gStatus = testStep.getAssertionAt(j).status
def expect = testStep.getAssertionAt(j).getToken()
log.info "Expected Content: " + expect
3.清空property
def datasink = testCase.testSteps["DataSink"] String[] props = new String[datasink.getPropertyCount()]
props = datasink.getPropertyNames(); for (int i=0;i<props.size();i++)
{
datasink.setPropertyValue(props[i],"")
}
4.从test step中获取到结果
import com.eviware.soapui.model.testsuite.*
import com.eviware.soapui.impl.wsdl.teststeps.* def suiteRunner = (TestSuiteRunner) runner.getRunContext().getTestRunner()
def listResults = suiteRunner.getResults()
for (TestCaseRunner run : listResults){
def stepResults = run.getResults();
for(TestStepResult step : stepResults){
if(!step.getStatus().toString().equals("OK")){
def local = step.getTestStep()
def caseName = local.getTestCase().getName();
def modalItem = local.getModelItem()
log.info modalItem
if (modalItem instanceof JdbcRequestTestStep){
log.error "TestCase " + caseName + " step " + local.getName() + " failed"
log.error "JDBC step failed, query was: " + local.getQuery()
log.error "Response content:" + local.getResponseContent()
}
if(modalItem instanceof WsdlTestRequestStep){
log.error "TestCase " + caseName + " step " + local.getName() + " failed"
log.error "Request: " + modalItem.getTestRequest().getResponse().getRequest().getRequestContent()
log.error "Response: " + modalItem.getTestRequest().getResponse().getContentAsXml()
}
if(modalItem instanceof WsdlRunTestCaseTestStep){
log.error "TestCase " + caseName + " step " + local.getName() + " failed"
def target = local.getTargetTestCase()
}
}
5. 使用context
def myVar = context.expand( ‘${#TestCase#SourceTestStep}’) //expand TestCase property value into the new variable
context.testCase // returns the current testCase handle
context.expand( '${QuerySubsPlanList - Request 1#Response#//count(*:QuerySubsPlanListResponse[1]/SubsPlanDtoList[1]/SubsPlanDto)}')
for ( i in 1..numElements.toInteger()) {
collection2.add(context.expand( '${QuerySubsPlanList - Request 1#Response#//*:QuerySubsPlanListResponse[1]/SubsPlanDtoList[1]/SubsPlanDto['+ i + ']/SubsPlanCode[1]}'))
}
6. 获取TestRunner的参数
testRunner.testCase.getTestStepByName(“TestStepName”)
testRunner.testCase
testRunner.testCase.testSuite.project.testSuites[“My_TestSuite”]
7. 转换String和Integer
anyStringVar = anyIntegerVar.toString()
anyIntegerVar = anyStringVar.toInteger()
8. 获取到project,testsuite,testcase,teststep
def project = testRunner.testCase.testSuite.project
def project = context.testCase.testSuite.project def myTestSuite = project.getTestSuiteAt(IndexNumber)
def myTestSuite = project.getTestSuiteByName(“Name of the TestSuite”) def myTestCase = myTestSuite.getTestCaseAt(IndexNumber)
def myTestCase = myTestSuite.getTestCaseByName(“Name of the TestCase”) def myTestStep = myTestCase.getTestStepAt(IndexNumber)
def myTestStep = myTestCase.getTestStepByName(“Name of the TestStep”)
SoapUI中Groovy的实用方法的更多相关文章
- soapUI参数中文乱码问题解决方法 (groovy脚本中文乱码)
soapUI参数中文乱码问题解决方法 可能方案1: 字体不支持中文,将字体修改即可: file-preferences-editor settings-select font 修改字体,改成能显示中文 ...
- excel文件的groovy脚本在SoapUI中进行数据驱动测试
SoapUI Pro具有从外部文件读取数据的功能,例如:excel,csv等.但SoapUI不提供从excel文件读取数据的功能.因此,为了从SoapUI中的excel文件中读取数据,我们需要在gro ...
- [转]js中几种实用的跨域方法原理详解
转自:js中几种实用的跨域方法原理详解 - 无双 - 博客园 // // 这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同 ...
- 使用Groovy处理SoapUI中Json response
最近工作中,处理最多的就是xml和json类型response,在SoapUI中request里面直接添加assertion处理json response的话,可以采用以下方式: import gro ...
- Python中os和shutil模块实用方法集…
Python中os和shutil模块实用方法集锦 类型:转载 时间:2014-05-13 这篇文章主要介绍了Python中os和shutil模块实用方法集锦,需要的朋友可以参考下 复制代码代码如下: ...
- Python中os和shutil模块实用方法集锦
Python中os和shutil模块实用方法集锦 类型:转载 时间:2014-05-13 这篇文章主要介绍了Python中os和shutil模块实用方法集锦,需要的朋友可以参考下 复制代码代码如下: ...
- SoapUI API + Groovy API + Difference with Java
用soapUI进行webservice测试过程中,必不可少的要用到soapUI封装的代码.我们一起学习吧:) SoapUI 5.1.2 API:http://www.soapui.org/apidoc ...
- 工作随笔——Java调用Groovy类的方法、传递参数和获取返回值
接触Groovy也快一年了,一直在尝试怎么将Groovy引用到日常工作中来.最近在做一个功能的时候,花了点时间重新看了下Java怎么调用Groovy的方法.传递参数和获取返回值. 示例Groovy代码 ...
- 在Swift中使用JavaScript的方法和技巧
本文作者Nate Cook是一位独立的Web及移动应用开发者,是继Mattt大神之后NSHipster的主要维护者,也是非常知名活跃的Swift博主,并且还是支持自动生成Swift在线文档的Swift ...
随机推荐
- iOS CoreMotion框架(传感器)
我们知道iOS的应用真的太多了,很多应用让我们惊叹不已!!!很多意想不到的应用! 比如: 1.电子罗盘指南针之类的应用-让我们知道方向. 2.运动类型软件-让我们知道我们跑步多少公里. 3.社交软件中 ...
- MyBatis学习总结_09_使用MyBatis Generator自动创建代码
一.构建一个环境 1. 首先创建一个表: CREATE TABLE t_user ( USER_ID INT NOT NULL AUTO_INCREMENT, USER_NAME CHAR(30) N ...
- NAND Flash【转】
转自:http://www.cnblogs.com/lifan3a/articles/4958224.html 以Micron公司的MT29F2G08为例介绍NAND Flash原理和使用. 1. 概 ...
- flex 4 布局样式
Flex 4 样式与布局 第一篇 Flex 4 与自定义布局(Layout) Flex 4/Spark组件架构的新功能之一是可以定制一个容器的布局而不必改变容器本身.您需要做的就是定义一个自定义布局. ...
- Java @override报错的解决方法
在eclipse中导入工程后@Overide报错 到入工程后,所有的@Override都报如下错误: Multiple markers at this line - The method getCou ...
- vim 添加到右键 windows
>>>> 在windows下 <<<< ++ 在鼠标右键显示“用vim编辑”++ 1.删掉注册表中的HKEY_CLASSES_ROOT\*\shelle ...
- How Uuencoding Works
做题目学习 https://www.zhihu.com/question/26598476/answer/45396765 http://email.about.com/od/emailbehind ...
- 概述hibernate入门安装配置
1.jdbc连接的优缺点 JDBC的优点 直接底层操作,提供了很简单.便捷的访问数据库的方法,跨平台性比较强.灵活性比较强,可以写很复杂的SQL语句. JDBC的缺点 1).因为JAVA是面向对象的, ...
- 浅谈B+树索引的分裂优化(转)
http://www.tamabc.com/article/85038.html 从MySQL Bug#67718浅谈B+树索引的分裂优化 原文链接:http://hedengcheng.com/ ...
- MVC 中使用扩展方法
扩展方法(Extension Method)是给那些不是你拥有.因而不能直接修改的类添加方法的一种方便的办法. 一.使用扩展方法 1.定义一个购物车的类-ShoppingCart using Sys ...