【 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 format
import 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 case
import 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);

SoapUI offen used scripts的更多相关文章

  1. SoapUI--the use of Script Library

    SoapUI--the use of Script Library 有两种方法在soapUI中引用自己的groovy脚本库. 方法一:把自己的script folder放到soapUI install ...

  2. [SoapUI] Global Scripts For Reusability

  3. SoapUI命令行方式运行

    http://stackoverflow.com/questions/9220132/soapui-groovy-script-calls-to-command-line SoapUI支持用命令行方式 ...

  4. SoapUI中XML解析

    From http://www.robert-nemet.com/2011/11/groovy-xml-parsing-in-soapui.html Introduction Since soapUI ...

  5. SoapUI接口测试-验签值处理-调用java的加密jar包

    转载自:https://www.jianshu.com/p/7c672426a165 一. 背景: 调用接口时有个请求参数是对请求入参按一定规则进行加密生成的验签值,每次不同参数的请求生成唯一的验签值 ...

  6. [SoapUI] Property Expansion in soapUI

    1. Property Expansion in soapUI SoapUI provides a common syntax to dynamically insert ("expand& ...

  7. C# 用SoapUI调试WCF服务接口(WCF中包含用户名密码的验证)

    问题描述: 一般调试wcf程序可以直接建一个单元测试,直接调接口. 但是,这次,我还要测试在接口内的代码中看接收到的用户名密码是否正确,所以,单一的直接调用接口方法行不通, 然后就想办法通过soapU ...

  8. SQLMap Tamper Scripts Update 04/July/2016

    SQLMap Tamper Scripts Update apostrophemask.py Replaces apostrophe character with its UTF-8 full wid ...

  9. SOAPUI使用教程-REST功能测试

    当创造了SoapUI功能测试用例,常见的情况是,你调用一些REST资源和验证其响应检查返回正确的结果.这可以容易地实现: 添加一个REST请求到新的test step或现有的TestCase 添加断言 ...

随机推荐

  1. Selenium私房菜系列9 -- 我遇到的问题及解决问题的方法

    Selenium私房菜系列10 -- 我遇到的问题及解决问题的方法

  2. ABC3D创客项目:小风扇

    风扇是我们纳凉的好帮手,然而大多的风扇都体积庞大不易携带.利用电池进行供电能让风扇变得更加便捷,下面我们利用电池供电的原理制作出一个风扇. 工作原理: 这个OK风扇的主要能源来自于后面的7号电池,风扇 ...

  3. UIButton 左对齐 省略号最右边

    //左对齐 [_btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; //省略号靠右侧 _btn.ti ...

  4. 数据库_4_SQL介绍

    SQL SQL:Structured Query Language,结构化查询语言(数据已查询为主:99%是在进行查询操作)    what型语言,而非how型的语言. SQL分为三个部分: DDL: ...

  5. CPP-练习

    HW: 1.局部变量能否和全局变量重名? 答:能,局部会屏蔽全局.要用全局变量,需要使用"::" ;局部变量可以与全局变量同名,在函数内引用这个变量时,会用到同名的局部变量,而不会 ...

  6. 使用gcc -g编译,gdb调试时仍然存在“no debug symbols found”的错误

    今天为调试一段代码,使用gcc将程序用-g选项重新编译.但是使用gdb进行debug时,仍然出现“no debug symbols found”的错误.仔细检查了一下Makefile,原来后面定义的连 ...

  7. Bootstrap 基本按钮

    本章将通过实例讲解如何使用Bootstrap按钮,任何带有class.btn的元素都会继承圆角灰色默认按钮样式,但Bootstrap提供了一些选项来定义按钮的样式. 实例 <!DOCTYPE h ...

  8. java在线聊天项目0.2版本 制作客户端窗体,使用swing(用户界面开发工具包)和awt(抽象窗口工具包) BorderLayout布局与GridLayout布局不同之处 JPanel设置大小

    代码如下: package com.swift; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JBu ...

  9. ios之UIPopoverController

    UIPopoverController是iPad上的iOS开发会常用到的一个组件(在iPhone设备上不允许使用),这个组件上手很简单,因为他的显示方法很少,而且参数简单,但我在使用过程中还常碰到各种 ...

  10. 学c++有感

    第一次学习这么课程的时候,感觉课堂和教材的内容基本上都能接受和理解,但真正实际动手编写程序又觉得一片空白无从下手,可谓是“欲起平之恨无力.”一开始编写程序时,总是出现错误,从而产生了恐惧感,认为自己不 ...