【问题标题】:Karate - How to delay all scenarios?空手道 - 如何延迟所有场景?
【发布时间】:2017-10-31 06:32:30
【问题描述】:

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

【问题讨论】:

  • 我认为你唯一能做的就是并行执行
  • @HomayounBehzadian 没有人!这不是重点,我只是想执行我的延迟函数,然后一个接一个地执行我的场景

标签: unit-testing karate


【解决方案1】:

使用callonce:

* callonce sleep 60

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 2023-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多