Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karate - How to delay all scenarios?

I have a 10 scenarios, all of them must have 1 min delay after executing background. I call my delay function in background. The problem is that all scenarios call background, and I have to wait 10 minutes.
Is there a way to call my wait function one for all scenarios?
This is my background and one of my scenarios:

  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
}
  """
like image 933
ehsan shirzadi Avatar asked Oct 31 '17 06:10

ehsan shirzadi


Video Answer


1 Answers

Use callonce:

* callonce sleep 60
like image 99
Peter Thomas Avatar answered Sep 29 '22 07:09

Peter Thomas