问题
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