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. wordpress自定义栏目

    开启自定义栏目:点击头顶的“显示选项”,勾选“自定义栏目” 然后编辑文章时,即可看见 实验: 定义名称为:play_url ,值为:http://www.xiami.com/widget/635357 ...

  2. Sublime Text 2安装汉化破解、插件包安装教程

    原文地址: Sublime Text 2安装汉化破解.插件包安装教程_百度经验 http://jingyan.baidu.com/article/ff4116259b057c12e48237b8.ht ...

  3. iOS:CALayer的隐式动画的详解

    CALayer的隐式动画属性: •每一个UIView内部都默认关联着一个CALayer,称这个Layer为Root Layer.所有的非Root Layer都存在着隐式动画,隐式动画的默认时长为1/4 ...

  4. Android 广播(内部类)

    1.广播定义在一个单独的文件中 源码: public class MessageReceiver extends BroadcastReceiver{ @Override public void on ...

  5. c#对文件进行MD5加密校验

    public static string GetFileMd5Hash(string strFileFullPath) { // Create a new instance of the MD5Cry ...

  6. Linux内核同步机制之(三):memory barrier【转】

    转自:http://www.wowotech.net/kernel_synchronization/memory-barrier.html 一.前言 我记得以前上学的时候大家经常说的一个词汇叫做所见即 ...

  7. python 列表(list)去除重复的元素总结

    方法一: 将list作为set的构造函数构造一个set,然后再将set转换会list就可以 >>> myList = [1, 2, 3, 3, 2, 2, 4, 5, 5] > ...

  8. How to: Read Object Data from an XML File

    This example reads object data that was previously written to an XML file using the XmlSerializer cl ...

  9. poj1961Period(next数组)

    http://poj.org/problem?id=1961 对于next数组只能说略懂,其中精髓还是未完全领会 大体是本串相同前缀与后缀的最大长度,读不懂?看串abcdab 这里所说前缀与后缀都为a ...

  10. 基于UltraVNC实现客户端远程控制

    前言 一般远程就直接用windows自带的,配置好动态IP花生壳,在任何地方都可以连回机子.最近项目里遇到这么个情况,需要快速接入远程控制功能,客户机的IP每次都会变,并且都是在外网,这样,就必须使用 ...