我正在进行soapui测试,其中我想保存请求&响应后缀为todaydate。
这是我的代码:
// Create a File object representing the folder 'A/B'
def folder = new File( 'C:/Project/SOAPUI' )
// If it doesn't exist
if( !folder.exists() ) {
// Create all folders up-to and including B
folder.mkdirs()
}
def myOutFile = "C:/Project/SOAPUI/test_request.txt"
def request = context.expand( '${test#Request}' )
def f = new File(myOutFile)
f.write(request, "UTF-8")
=====================
我希望文件名为test_request(+今天的日期)
你能给我一些选择吗?
答案 0 :(得分:2)
这是一个选项:
def myOutFile = "C:/Project/SOAPUI/test_request_${(new Date()).format('yyyy-MM-dd')}.txt"
输出看起来像 C:/Project/SOAPUI/test_request_2015-08-30.txt