Api 通过SoapUI将结果导出到文本文件中

Api 通过SoapUI将结果导出到文本文件中,api,soapui,dotmailer,Api,Soapui,Dotmailer,我正在使用dotmailer.com ESP和SoapUI调用API。我可以获得JSON格式的活动摘要,但我也想将活动摘要提取到文本文件中,但找不到任何方法。有人能帮忙吗? 谢谢。您可以使用groovy来完成。只需在测试用例中添加一个groovy脚本testStep,就可以从前面的测试步骤获得响应并保存到文件中。由于您的问题中没有太多细节,因此一般的解决方法可以是: // get the test step def testRequest = context.testCase.getTestSt

我正在使用dotmailer.com ESP和SoapUI调用API。我可以获得JSON格式的活动摘要,但我也想将活动摘要提取到文本文件中,但找不到任何方法。有人能帮忙吗?
谢谢。

您可以使用groovy来完成。只需在测试用例中添加一个
groovy脚本testStep
,就可以从前面的测试步骤获得响应并保存到文件中。由于您的问题中没有太多细节,因此一般的解决方法可以是:

// get the test step
def testRequest = context.testCase.getTestStepByName('Test Request')
// get the response
def response = testRequest.getPropertyValue('Response')
// create a file
def file = new File('C:/temp/response.txt');
// save the response to it
file << response
//获取测试步骤
def testRequest=context.testCase.getTestStepByName('测试请求')
//得到回应
def response=testRequest.getPropertyValue('response')
//创建一个文件
def file=新文件('C:/temp/response.txt');
//保存对它的响应

你是说,想记录收到的响应吗?不,实际上,我想导出数据本身。但我认为这是不可能的,对吗?哪种格式?将数据从json提取到csv文件还是仅提取json格式?然后您可以使用groovy脚本测试步骤。输入的是json,输出的可以是任何你想要的。最终结果实际上是csv,但在第一个数据输出中也可以是json。然后可以将其转换为csv或其他输出。我的经理现在放弃导出数据。没有必要回答这个问题。谢谢大家。