Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Groovy soapui报告_Groovy_Soapui - Fatal编程技术网

Groovy soapui报告

Groovy soapui报告,groovy,soapui,Groovy,Soapui,我使用的是SOAPUI的开源版本。 我的要求是将SOAP响应XML导出到一个文件(e.f txt)中。为此,我在开源中找不到任何这样的选项。请建议是否有任何方法可以做到这一点,或者Groovy脚本是解决方案。如果是,则如何保存。如果要保存简单的SOAP测试步骤响应,可以使用以下代码添加groovy脚本: // get your response def soapResponse = context.expand('${YourSOAPRequest#Response}') // create t

我使用的是SOAPUI的开源版本。
我的要求是将SOAP响应XML导出到一个文件(e.f txt)中。为此,我在开源中找不到任何这样的选项。请建议是否有任何方法可以做到这一点,或者Groovy脚本是解决方案。如果是,则如何保存。

如果要保存简单的SOAP测试步骤响应,可以使用以下代码添加groovy脚本:

// get your response
def soapResponse = context.expand('${YourSOAPRequest#Response}')
// create the file
def file = new File("C:/Temp/testSO/response.xml")
file.mkdirs()
// save the response
file.write(soapResponse)
请注意,
YourSOAPRequest
是SOAP测试步骤的名称


此外,如果您想保存测试套件或测试用例的所有测试步骤响应,此答案可以帮助您:

您可以使用
-a
-a
开关从运行测试。

感谢@albciff指导我完成答案。我还找到了一种方法,当我们有一个变量而不是一个静态的SOAP请求名称时,进行定位:

def soapResponse=testRunner.testCase.getTestStepByName(testStepName).getProperty(“响应”).getValue()


现在,这个响应可以用来保存

@albciff..r答案对我有用。但是,如果我想在def soapResponse=context.expand(“${YourSOAPRequest#Response}”)行中为我的SOAPRequest传递一个变量,该怎么办out@NipunKumar对不起,我不明白你的问题,你能更详细地解释一下你的问题吗?@albciff..我通过了测试步骤名称(即Soap请求名称)在变量中,执行testStep。现在我想使用这个变量(而不是静态测试步骤名称)捕获响应,例如,如果def A=“SoapRequest1”,那么我想在下面的代码行中使用A,而不是“SoapRequest1”……def soapResponse=context.expand(“${SoapRequest1#response}”)@NipunKumar,如果您在字符串变量中有测试步骤名称,您可以简单地使用
+
运算符连接此字符串以生成“expand”字符串,请查看以下代码:
def a=“SOAPRequest1”;def soapResponse=context.expand('${'+A+'#Response}')@albciff…感谢您的快速回答。我用双引号连接。我还想出了另一种工作方式:)