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 ...
随机推荐
- 注册表修改PSD关联photoshop
当psd文件右键点击--打开方式--选择默认程序photoshop也没用的时候,那应该是注册表未关联,可以试下以下方法: 第一步:在运行框中输入regedit,打开注册表编辑器,将HKEY_CLASS ...
- iOS:核心动画之动画组CAAnimationGroup
CAAnimationGroup——动画组 动画组,是CAAnimation的子类,可以保存一组动画对象,将CAAnimationGroup对象加入层后,组中所有动画对象可以同时并发运行 属性说明: ...
- CodeForces485A——Factory(抽屉原理)
Factory One industrial factory is reforming working plan. The director suggested to set a mythical d ...
- Jquery中用offset().top和offsetTop的比较
今天,想测试一个div与顶部的距离,用的是.offsetTop,但是offsetTop获得的值,怎么都打印不出来.折腾了半天,打印的结果都是undefined,虽然网上很多资料都说返回的是数值.虽然这 ...
- jquery的extend和fn.extend的使用说明
jQuery.fn.extend(object); 对jQuery.prototype进得扩展,就是为jQuery类添加“成员函数”.jQuery类的实例可以使用这个“成员函数”. jQuery为开发 ...
- mysql 授权 打开全部
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "."FLUSH PRIVILEGES;
- Java安全编码之用户输入
0x00 安全引言 1.传统Web应用与新兴移动应用 (1)传统Web应用:浏览器 HTTP 服务器(2)新兴移动应用:APP HTTP 服务器 从安全角度看,传统Web应用与新兴移动应用没有本质区别 ...
- 你猜……你再猜
『男』:你喜欢我吗? 『女』:你猜. 『男』:喜欢. 『女』:你再猜. 『男』:--
- env1
给新手参考的Cadence Allegro快捷键 原文链接:http://www.eda365.com/thread-30935-1-1.html 发上我的快捷键给新手参考,我也是在LULU给我的EN ...
- .NET_Framework_version_history
http://en.wikipedia.org/wiki/.NET_Framework_version_history