我有10个场景,所有这些场景在执行后台后都必须有1分钟的延迟。我在后台调用延迟功能。问题是所有场景都需要背景,我必须等待10分钟 有没有办法在所有场景中调用我的等待函数? 这是我的背景和我的一个场景:
Background:
* call read('classpath:cleanup.feature')
* def login = call read('classpath:init/init.user.feature')
* def sleep =
"""
function(seconds){
for(i = 0; i <= seconds; i++)
{
java.lang.Thread.sleep(1*1000);
karate.log(i);
}
}
"""
* call sleep 60
Scenario: Correct
# Step one: requesting a verification code
Given url karate.get('urlBase') + "account/resendMobileActivationVerificationCode"
And request {"mobile": #(defaultMobile)}
And header X-Authorization = login.token
And header NESBA-Authorization = login.nesba
When method post
Then status 200
And match response ==
"""
{
"status":0,
"message":"#(status0persianMessage)",
"result": true
}
"""
答案 0 :(得分:2)
使用callonce
:
* callonce sleep 60