简体   繁体   中英

Returning Variable from Feature File With Multiple Scenarios - Karate

We already know that scenarios are run paralelly. But we had the case where we need to return variables from feature files (that are gonna be called from another feature file).

We had multiple scenarios in the feature file as below:

@mutation
Feature: Test GraphQL Create Item
Background:
    Given url baseUrl
    * configure headers = { Authorization: '#(token)' }

@negative
Scenario: Create item unauthorized
    * configure headers = { Authorization: ""}
    #Features calling function and others
    And match response.errors[0].message == errorUnauthorized

Scenario: Create story authorized
    #Features calling function and others
    And def idItem = response.data.CreateItem.id

We are reusing the feature file above to obtain variable to be used on another feature file. However it seems that the other feature files fail intermittently complaining the variables obtained from the other feature file is null.

My assumption is that the returned variable is not returned properly since there are more than one scenarios on the feature file. We tried deleting the @negative scenario and have only exactly 1 scenario. Suddenly the intermittent failures gone.

Is there any way to avoid this intermittent failures while still retaining the ability to run scenarios paralelly?

Thanks

Can't say without seeing your code. But you can try using the @parallel=false annotation in the "calling" feature file: https://github.com/intuit/karate#parallelfalse

Otherwise this may be a bug in Karate - so please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM