5

我有 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
}
  """
4

1 回答 1

7

使用callonce

* callonce sleep 60
于 2017-10-31T17:53:37.447 回答