Karate - How to delay all scenarios?
Asked Answered
R

1

5

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
}
  """
Rhesus answered 31/10, 2017 at 6:32 Comment(2)
I think only way you can do is parallel executionMeshed
@HomayounBehzadian No man! It's not the point, I just want to execute my delay function and then execute my scenarios one after anotherRhesus
B
7

Use callonce:

* callonce sleep 60
Brickbat answered 31/10, 2017 at 17:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.