问题描述
我有一个请求,如果请求正在处理中或已通过,则我将在响应参数中获取正在处理"或已提交".我能够轮询并获取状态为正在处理"或已提交"的信息,但是在此之后,如果我在轮询5次后仍未达到预期的状态,就无法使请求失败.某些重试未提供预期的响应后,我如何无法使请求失败?
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?
推荐答案
答案在您的问题中,
我假设您正在使用js函数进行轮询,如果是这样,则可以从中添加布尔值return
,如果条件不满足return false
或条件满足return true
,则声明从功能文件返回的值.
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;
}
}
"""
功能
* def statusFound = pollingFunc("Processed" )
* assert (statusFound == true)
如果在轮询后仍未获得预期状态,则assert
将无法通过测试
If the expected status not obtained after polling the assert
will fail the test
这篇关于空手道轮询后,有没有办法断言和使请求失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!