Is there a way to assert and fail a request after polling in karate?

∥☆過路亽.° 提交于 2021-02-05 07:16:15

问题


I have a request where i get Processing or Submitted in a response parameter if the request is in process or passed respectively. I am able to poll and get if the status is "Processing" or"Submitted" but after that I am unable to fail the request if still i am not getting the expected status after polling for 5 times. How can i fail request after certain retries do not provide me expected response?


回答1:


The answer is in your question,

I assume you are polling using a js function, If so you can add a boolean return from that, if you condition not met return false or if condition met return true then assert the value returned from your feature file.

* def pollingFunc =
"""
function(x) {
     // your polling logic which retrives status
     if (status == x) {
      return true;
     } 
     else{
      return false;
     } 
} 
"""

In feature

* def statusFound = pollingFunc("Processed" )
* assert (statusFound == true) 

If the expected status not obtained after polling the assert will fail the test



来源:https://stackoverflow.com/questions/53534308/is-there-a-way-to-assert-and-fail-a-request-after-polling-in-karate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!