請按照下列步驟操作:
- 去考套房
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