【 Groovy Step 】//get properties from testCase, testSuite and project in groovy step
def testCaseProperty  = testRunner.testCase.getPropertyValue( "MyProp" )  // testCase property
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )  // testSuite property
def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )//project property// set properties to testCase,testSuite and project in groovy step
testRunner.testCase.getProperty("MyProp").setValue("MyValue");   // set testCase property
testRunner.testCase.setPropertyValue("MyProp","MyValue");testRunner.testCase.testSuite.getPropertyValue( "MyProp" ).setValue("MyValue");  // set testSuite property
testRunner.testCase.testSuite.setPropertyValue("MyProp","MyValue");testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" ).setValue("MyValue");  // set project property
testRunner.testCase.testSuite.project.setPropertyValue("MyProp","MyValue");// get the response content
String  responseStr = testRunner.testCase.testSteps["MyStep"].testRequest.response.contentAsString;
// convert the response content to JSON formatimport groovy.json.JsonSlurper;
JsonSlurper slurper = new JsonSlurper();
Object  responseObj = slurper.parseText(responseStr);// run another test step under current test case
testRunner.runTestStepByName("MyStep");// run another test step under another test caseimport com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner;
def testcase = testRunner.testCase.testSuite.project.testSuites["MyTestSuite"].getTestCaseByName("MyTestCase");
WsdlTestCaseRunner runner = new WsdlTestCaseRunner( testcase,null );
runner.runTestStepByName("AnotherStep");【 Script Assertion 】
def number = messageExchange.modelItem.testCase.testSteps["Properties"].getPropertyValue("userId")
def testCaseProperty  = messageExchange.modelItem.testCase.getPropertyValue("MyProp");
def testSuiteProperty = messageExchange.modelItem.testCase.testSuite.getPropertyValue("MyProp");
def projectProperty = messageExchange.modelItem.testCase.testSuite.project.getPropertyValue("MyProp");
// project property can be also like:
def projectProperty = messageExchange.modelItem.project.getPropertyValue("MyProp");def projectProperty = context.expand('${#Project#MyProp}');  // 注意,用双引号貌似会出错
def testSuiteProperty = context.expand('${#TestSuite#MyProp}');// get the response content
def responseContent = messageExchange.responseContent;
// get the response content and convert to JSON format
def jsonObj = net.sf.json.JSONSerialize.JSONSerializer.toJSON(messageExchange.responseContent);

转载于:https://www.cnblogs.com/tomweng/p/5567697.html

SoapUI offen used scripts相关推荐

  1. soapui + groovy 接口自动化测试 第八章

    一波小团战!  1.操作excel的groovy脚本 package pubimport jxl.* import jxl.write.Label import jxl.write.WritableW ...

  2. executequery方法_【接口测试】soapui中数字、字符串、日期时间、数据库连接参数化的设置方法...

    先回顾下前几篇soapui工具操作文章: 在soapui里面使用groovy脚本生成测试报告的方法 在soapui里面用groovy传递cookie身份信息的方法 soapui中进行接口响应数据的关联 ...

  3. SOAPUI请求及mockservice 使用

    1.新建soap Project,输入wsdl的地址,运行request                                                             2.邮 ...

  4. 初始化Mysql系统报错,begin failesd--conpilation aborted at scripts........

    在编译安装Mysql之后进行初始化,但是出现了报错 初始化mysql scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/us ...

  5. SoapUi测试,测试相关问答知识

    2019独角兽企业重金招聘Python工程师标准>>> SoapUi测试 http://www.csdn123.com/html/topnews201408/39/14939.htm ...

  6. Composer scripts脚本:事件列表与脚本触发

    脚本 什么是脚本? 一个脚本,在 Composer 中,可以是一个 PHP 回调(定义为静态方法)或任何命令行可执行的命令.脚本对于在 Composer 运行过程中,执行一个资源包的自定义代码或包专用 ...

  7. npm scripts的生命周期管理

    2019独角兽企业重金招聘Python工程师标准>>> 我们平时阅读一些开源项目,可能会发现有些项目的package.json里的scripts区域定义的脚本很复杂,令人眼花缭乱. ...

  8. soapUi 接口测试

    SoapUI是一个开源测试工具,通过soap/http来检查.调用.实现Web Service的功能/负载/符合性测试. SoapUI下载地址:https://www.soapui.org/,下载开源 ...

  9. SoapUI实践:自动化测试、压力测试、持续集成

    因为项目的原因,前段时间研究并使用了 SoapUI 测试工具进行自测开发的 api.下面将研究的成果展示给大家,希望对需要的人有所帮助. SoapUI 是什么? SoapUI 是一个开源测试工具,通过 ...

最新文章

  1. device.cpp
  2. 日事清【员工绩效】功能活动上线!
  3. 学习EF4的一些基础参考资料
  4. 【CSS3】好玩的动画线框
  5. html加载出来图片乱掉,HTML基础 img alt 图片加载失败时,出现替代文本
  6. Vue中watch的简单应用
  7. c++从字符串中提取数字求和_【函数应用】单元格文本内提取数字并求和
  8. 在PhotoShop中改像素m*n
  9. 浅谈项目管理中的四要素
  10. 提示tun虚拟网卡没有安装_Win10家庭版通过Hyper-V安装Centos7+Python3.7过程总结
  11. 扫雷打开的初始区域递归_Python:游戏:写一个和 XP 上一模一样的“扫雷”!
  12. 用jdbc连接hive server需要用到的 几个jar包
  13. 【工具使用系列】一小时学会使用MATLAB OPC 工具箱(OPC Toolbox)
  14. DDL DML DCL 简介
  15. 数据库系统异常排查之思路
  16. 检测到非法调试,F12被管理员禁用解决方法
  17. 硬石-专题04 步进电机控制(第1节)_步进电机基本知识介绍1
  18. ffmpeg 用 -ss指定起始时间
  19. 墨羽卿画第二章第5节:另一个世界,腊月廿四
  20. 微信小程序:上传的图片显示旋转问题

热门文章

  1. Java 定义一个人类Person
  2. 虚拟机安装图形化界面
  3. 5G时代来临,前端开发工程师必须了解的音视频入门基础知识
  4. 【计算机视觉与深度学习】全连接神经网络(一)
  5. 华为鸿蒙系统动画过滤,华为鸿蒙系统细节曝光 UI重绘动画多/系统简介更流畅...
  6. 小程序组件获取元素宽高失效 和canvas绘制问题
  7. 】20款优秀的移动产品原型和线框图设计工具
  8. ROS学习记录(一) Plugin插件
  9. openjudge 1.5.37 雇佣兵
  10. Openkruise/rollouts 源码解读