Generally speaking, we all know the Soap UI more or less, it's a automation testing tool for webserivce, we can code abundant types of assertion. We have to do a little researches if we want to be a master on it, e.g. pass the property between test step and groovy script, now look at the example.
we want to get the response of the webservice and then to pass a value to another webservice as a property
1. create two rest services
2. create test suite\test case
3. create test step 1 to call the rest_service_1
Run this step we'll get the JSON data, as we know we can get entire JSON response via a request in a Groovy script assertion:
def booksRoot = net.sf.json.JSONSerializer.toJSON(messageExchange.responseContent);
but we cannot pass it to another steps from assertion, how do we do?
4. create a Groovy Script
def paraNode = net.sf.json.JSONSerializer.toJSON(context.expand( '${books#Response}' ))
we got it, key: context.expand( '${books#Response}' )
5. perfect the script
def paraNode = net.sf.json.JSONSerializer.toJSON(context.expand( '${books#Response}' ))
def volume = paraNode.get("Result").get("aaaa").get("Status")
return volume
6
7
8. the result of the response we want has been pass to the q in SearchVolumeLibrary step as a property
9. Happy Ending.
相关推荐
Groovy Script 入门 Groovy 脚本入门
Groovy in Action, Second Edition is the undisputed definitive reference on the Groovy language. Written by core members of the Groovy language team, this book presents Groovy like no other can—from ...
NULL 博文链接:https://leon1509.iteye.com/blog/1541387
groovy in action中文版,带标签
The development of Groovy, from version 1.0 covered in the first edition of this book until the current version 2.4, has closed what used to be a syntax gap by providing enums, annotations, generics, ...
Groovy in Action Groovy实战 英文第2版 Groovy in Action Groovy实战 英文第2版
The result is the true definitive guide to the new Groovy language., Groovy in Action introduces Groovy by example, presenting lots of reusable code while explaining the underlying concepts....
groovy一般程序的script,适合Groovy初学者
groovy in action 中文版 2017.11 groovy in action 中文版 2017.11
Groovy in Action的源代码。Groovy in Action的源代码。
Groovy in Action[文字版][中文] Groovy in Action[文字版][中文]
Groovy_in_Action.pdf Groovy经典入门.pdf 使用Grails快速开发Web应用.pdf 在Eclipse里使用Grails类创建工具.pdf Programming Groovy. Dynamic Productivity for the Java Developer.pdf等一系列groovy资源
Groovy IN ACTION
Groovy in Action, Second Edition is a thoroughly revised, comprehensive guide to Groovy programming. It introduces Java developers to the dynamic features that Groovy provides, and shows how to apply ...
groovy+in+action 英文 学习groovy的好资料,实例比较多
Groovy in action 中英文,API
Groovy in Action, Second Edition describes the Groovy language, presents the library classes and methods that Groovy adds to the standard Java Development Kit, and leads you through a number of topics...
groovy in action 详细语法讲解,附例子程序, ofbiz 学习必备。
《Groovy in Action》是Groovy编程的综合指南,它向Java开发者介绍了Groovy提供的新的动态特性。为了呈现《Groovy in Action》,Manning再次从源头工作,与包括Groovy项目团队成员和经理在内的专家作者团队合作。其结果...