我正在发送JSON文件作为请求,并使用Groovy脚本为Rest Project在soap UI工具中获取响应。
但我在第2步中发现错误,因为它没有检索JSON文件的内容。以下是我的代码。
File file1 = new File("C:\\GroovyTest\\requests\\aaa.json")
List textLine = file1.readLines()
log.info textLine
context.put('textLine', textLine)
log.info textLine
${=new File("C:\\GroovyTest\\requests\\"+(context.get('filelist')).last()).text)
def fileList = context.get('fileList')
if (fileList != null)
{
def fileName = fileList.pop()
def newname = fileName[0..-5]
def response = context.expand( '${Step2#Response}' )
def f = new File("C:\\GroovyTest\\responses\\${fileName}_Response.xml")
f.write(response, "UTF-8")
if(fileList.size() >0)
{
testRunner.gotoStepByName("Step2")
}
}