请按照下列步骤操作:
- 去考套房
PostPaid
- 添加自定义属性说
DATA_STORE_PATH
并将其值改为目录名,你要保存的请求和响应
- 去考案例
- 禁用步骤2 &步骤3即
SaveInquiryReq
和SaveInquiryResponse
步骤。或者如果除了分别保存请求&响应之外没有其他工作完成,您也可以删除altoger。
- 点击第一步
BillInq
,点击断言,选择Script Assertion
,在这里看到更多的细节how to add script assertion
- 看看下面的脚本,然后单击确定
- 现在运行的第一步,你应该能够看到保存的请求和响应在上述目录
/**
* 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)
来源
2016-10-30 12:54:56
Rao
有将其在管线5.您可以测试套件性能和测试用例的屏幕截图中使用的脚本创建任何'file'对象?您是否在'Billing'测试步骤的'Script Assertion'中使用它。你看起来似乎有几个星期和不同的问题有问题。 – Rao
是的,我修复了报告自动生成现在我想记录每个肥皂测试步骤的原始请求和响应的步骤名称,我终于使用了上面的脚本,但是当我使用参考值时,我得到了提到的错误 –
感谢您的编辑。剧本在哪里?或步骤号码?顺便说一下,不知道为什么有多个groovy脚本。每一件事都可以一步完成。任何方式,请澄清。 – Rao