groovy.lang.MissingPropertyException:没有这样的 属性:class 的文件:第 5 行出现 Script7 错误
groovy.lang.MissingPropertyException: No such property: file for class: Script7 error at line 5
我正在编写 groovy 脚本来保存原始 soap 请求和响应,但我收到此错误:
groovy.lang.MissingPropertyException: No such property: file for class: Script7 error at line 5
这是脚本:
def myOutFile = context.expand( '${#TestSuite#fileName}' )+"_PostPaid-Success_Payment_BillInqReq.xml"
def response = context.expand( '${BillInq#Request}' )
def f = new File(myOutFile)
f.write(response, "UTF-8")
file.write(context.rawRequest,'utf-8')
请按照以下步骤操作:
- 转到测试套件
PostPaid
- 将自定义 属性 说
DATA_STORE_PATH
及其值添加到您希望保存请求和响应的目录名称中
- 转到测试用例
PostPaid_Success_Payment
- 禁用步骤 2 和步骤 3,即
SaveInquiryReq
和 SaveInquiryResponse
步骤。或者如果除了分别保存请求和响应之外没有完成其他工作,您也可以删除 altoger。
- 单击步骤 1
BillInq
,单击断言,选择 Script Assertion
,查看此处了解更多详细信息 how to add script assertion
- 有以下脚本,点击确定
- 现在你运行第1步,你应该可以看到上面提到的目录中保存的请求和响应
/**
* This script logs both request and response
*/
assert context.response, "Response is empty or null"
assert context.request, "Request is empty or null"
//Save the contents to a file
def saveToFile(file, content) {
if (!file.parentFile.exists()) {
file.parentFile.mkdirs()
log.info "Directory did not exist, created"
}
file.write(content)
assert file.exists(), "${file.name} not created"
}
def dirToStore = context.expand('${#TestSuite#DATA_STORE_PATH}')
def currentStepName = context.currentStep.name
def requestFileName = "${dirToStore}/${currentStepName}_request.xml"
def responseFileName = "${dirToStore}/${currentStepName}_response.xml"
//Save request & response to directory
saveToFile(new File(requestFileName), context.rawRequest)
saveToFile(new File(responseFileName), context.response)
我正在编写 groovy 脚本来保存原始 soap 请求和响应,但我收到此错误:
groovy.lang.MissingPropertyException: No such property: file for class: Script7 error at line 5
这是脚本:
def myOutFile = context.expand( '${#TestSuite#fileName}' )+"_PostPaid-Success_Payment_BillInqReq.xml"
def response = context.expand( '${BillInq#Request}' )
def f = new File(myOutFile)
f.write(response, "UTF-8")
file.write(context.rawRequest,'utf-8')
请按照以下步骤操作:
- 转到测试套件
PostPaid
- 将自定义 属性 说
DATA_STORE_PATH
及其值添加到您希望保存请求和响应的目录名称中 - 转到测试用例
PostPaid_Success_Payment
- 禁用步骤 2 和步骤 3,即
SaveInquiryReq
和SaveInquiryResponse
步骤。或者如果除了分别保存请求和响应之外没有完成其他工作,您也可以删除 altoger。 - 单击步骤 1
BillInq
,单击断言,选择Script Assertion
,查看此处了解更多详细信息 how to add script assertion - 有以下脚本,点击确定
- 现在你运行第1步,你应该可以看到上面提到的目录中保存的请求和响应
/**
* This script logs both request and response
*/
assert context.response, "Response is empty or null"
assert context.request, "Request is empty or null"
//Save the contents to a file
def saveToFile(file, content) {
if (!file.parentFile.exists()) {
file.parentFile.mkdirs()
log.info "Directory did not exist, created"
}
file.write(content)
assert file.exists(), "${file.name} not created"
}
def dirToStore = context.expand('${#TestSuite#DATA_STORE_PATH}')
def currentStepName = context.currentStep.name
def requestFileName = "${dirToStore}/${currentStepName}_request.xml"
def responseFileName = "${dirToStore}/${currentStepName}_response.xml"
//Save request & response to directory
saveToFile(new File(requestFileName), context.rawRequest)
saveToFile(new File(responseFileName), context.response)