[英]Not able to run the feature files written in karate as a cucumber feature in eclipse
[英]Calling karate feature with variable
在空手道中,您可以通過發送json / list和map來調用功能。 我嘗試了多種方法來發送值並在調用的功能中使用它,但是會引發錯誤
例如:
引發錯誤:路徑:$,實際:'',預期:'30e093da-c4e3-4ee0-b180-e5d0b4302d9f',原因:不是子字符串
步驟: * call read('Logcheck.feature') {requestId : "#(responseHeaders['request-id'][0])"}
在logCheck功能中,我嘗試使用#(requestId)
獲取requestId
Logcheck功能步驟
* def resultFromServiceLog = utils.getResultFromLog(baseUrl,'#(requestId)','service')
我嘗試了另一種方法將其分配給
* def x = {requestId : responseHeaders['request-id'][0]}
* call ('logcheck.feature;) x
我將發送json的另一種方法
* json req = {requestId : "#(responseHeaders['request-id'][0])"} * call read('logcheck.feature') req
logcheck.feature的步驟
* print req * def resultFromServiceLog = utils.getResultFromLog(baseUrl,'#(requestId)','service')
例如:
引發錯誤:com.intuit.karate.exception.KarateException:JavaScript評估失敗:utils.getResultFromLog(baseUrl,'#>(requestId)','service'),null
打印請求輸出為
[打印] {“ requestId”:“ c996f752-c288-40c7-9398-c913254971e6”}
您需要清楚使用嵌入式表達式,請再次閱讀文檔: https : //github.com/intuit/karate#rules-for-embedded-expressions
例如,這是錯誤的:
* def resultFromServiceLog = utils.getResultFromLog(baseUrl,'#(requestId)','service')
代替:
* def resultFromServiceLog = utils.getResultFromLog(baseUrl, requestId, 'service')
這是錯誤的:
* call ('logcheck.feature') x
您可能的意思是:
* call read('logcheck.feature') x
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.