这是
Script Assertion
对于相同的Soap请求步骤和需求
不需要
使用额外的Groovy脚本步骤。
剧本
//Change file name as needed
def fileName = '/file/path/to.csv'
def delimiter = ','
assert context.response, 'Response is empty or null'
def xml = new XmlSlurper().parseText(context.response)
def personalInfos = xml.'**'.findAll { it.name() == 'personarray1' }
//Create the list of data (person array)
def list = personalInfos.collect {info -> info.children()*.name().collectEntries{[(it): info."$it"] } }
def sb = new StringBuffer(list[0].keySet().join(delimiter))
sb.append('\n')
list.collect { sb.append(it.values().join(delimiter)).append('\n')}
log.info "Data going to be written into file: \n ${sb.toString()}"
new File(fileName).write(sb.toString())