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的实用方法的更多相关文章

  1. soapUI参数中文乱码问题解决方法 (groovy脚本中文乱码)

    soapUI参数中文乱码问题解决方法 可能方案1: 字体不支持中文,将字体修改即可: file-preferences-editor settings-select font 修改字体,改成能显示中文 ...

  2. excel文件的groovy脚本在SoapUI中进行数据驱动测试

    SoapUI Pro具有从外部文件读取数据的功能,例如:excel,csv等.但SoapUI不提供从excel文件读取数据的功能.因此,为了从SoapUI中的excel文件中读取数据,我们需要在gro ...

  3. [转]js中几种实用的跨域方法原理详解

    转自:js中几种实用的跨域方法原理详解 - 无双 - 博客园 // // 这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同 ...

  4. 使用Groovy处理SoapUI中Json response

    最近工作中,处理最多的就是xml和json类型response,在SoapUI中request里面直接添加assertion处理json response的话,可以采用以下方式: import gro ...

  5. Python中os和shutil模块实用方法集…

    Python中os和shutil模块实用方法集锦 类型:转载 时间:2014-05-13 这篇文章主要介绍了Python中os和shutil模块实用方法集锦,需要的朋友可以参考下 复制代码代码如下: ...

  6. Python中os和shutil模块实用方法集锦

    Python中os和shutil模块实用方法集锦 类型:转载 时间:2014-05-13 这篇文章主要介绍了Python中os和shutil模块实用方法集锦,需要的朋友可以参考下 复制代码代码如下: ...

  7. SoapUI API + Groovy API + Difference with Java

    用soapUI进行webservice测试过程中,必不可少的要用到soapUI封装的代码.我们一起学习吧:) SoapUI 5.1.2 API:http://www.soapui.org/apidoc ...

  8. 工作随笔——Java调用Groovy类的方法、传递参数和获取返回值

    接触Groovy也快一年了,一直在尝试怎么将Groovy引用到日常工作中来.最近在做一个功能的时候,花了点时间重新看了下Java怎么调用Groovy的方法.传递参数和获取返回值. 示例Groovy代码 ...

  9. 在Swift中使用JavaScript的方法和技巧

    本文作者Nate Cook是一位独立的Web及移动应用开发者,是继Mattt大神之后NSHipster的主要维护者,也是非常知名活跃的Swift博主,并且还是支持自动生成Swift在线文档的Swift ...

随机推荐

  1. Android 代码检查工具SonarQube

    http://blog.csdn.net/rain_butterfly/article/details/42170601 代码检查工具能帮我们检查一些隐藏的bug,代码检查工具中sonar是比较好的一 ...

  2. RedHat7 部署ELK日志分析系统

    一.ELK的组成二.工作流程三.环境准备四.正式安装 一.ELK的组成 ELK由ElasticSearch.Logstash和Kibana三部分组成,每一部分的功能及特点如下图所示: 二.工作流程 在 ...

  3. Android 如何处理崩溃的异常

    Android中处理崩溃异常    大家都知道,现在安装Android系统的手机版本和设备千差万别,在模拟器上运行良好的程序安装到某款手机上说不定就出现崩溃的现象,开发者个人不可能购买所有设备逐个调试 ...

  4. AE 栅格图分级渲染

    ArcEngine对矢量数据进行风格化实在是得心应手,同样的对于栅格图像也能进行风格化!以前没接触过,今天正好需要,做出了栅格图像的渲染!下面实现的思路: 1.定义渲染的一系列接口 2.判断图像是否建 ...

  5. Android--数据持久化之内部存储、Sdcard存储

    前言 之前一直在讲AndroidUI的内容,但是还没有完结,之后会慢慢补充.今天讲讲其他的,关于数据持久化的内容.对于一个应用程序而言,不可避免的要能够对数据进行存储,Android程序也不例外.而在 ...

  6. Mtk Android编译命令

    一.输入命令: cbk@YCS:~/work/k6/alps$ ./mk help Usage: (makeMtk|mk) [options] project actions [modules] Op ...

  7. 坏账,断供,四大国有资产管理公司(AMC):东方、长城、信达和华融

    在高房价大幅度下降以后,银行会认为你在贷款的时候的抵押物,已经不值钱了,比如已经下跌百分之五十了,那么,银行就会给贷款者一个通知——你的抵押物--房子,已经不值钱了,所以说,你必须立刻缴纳这一部分贬值 ...

  8. python-unexpected content storage modification出错

    提示以上错误,然后在pycharm中的文件内容和实际内容不一致 去我的文档-.PyCharm-system_cache,全部删除

  9. core--线程调度

    线程的调度和我们用人是同一个道理,假如我们是公司的CEO,你的手下有7名大将,10名美女,100000名普通员工,现在你的任务是在1年内情切慰问完所有的员工.你将如何安排这个行程?先从那些人开始?从哪 ...

  10. 谷歌的ajax.googleapis.com被墙导致访问很多国外网站很慢的解决方法

    比如访问StackOverflow, 更比如flexerasoftware.com(导致Visual Studio的打包程序InstallShield Limited Edition不能注册和下载) ...