1

I have feature file with a scenario that uses a variable eg: 1. I am calling this scenario from another feature file but this time I want to pass another variable eg: 2

Feature file A: generateDocument.feature

@generatedoc
Scenario: Verify able to generate document for user
    Given path somepath
    And header Content-Type = 'application/json'
    And request {"userId": "abc123"}
    When method POST
    Then status 200
    * table documentId
      | id         | docTitle | 
      | '#notnull' | "ijk"    | 
      | '#notnull' | "xyz"    | 
    And match response[*].id == $documentId[*].id
    And match response[*].title == $documentId[*].docTitle

Feature file B: useDocument.feature

call read('generateDocument.feature@generatedoc') { userId: 'abc456'}

So when I run feature file A, it should use the variable 'abc123', but when I run the feature file B, it should use the variable 'abc456'

But currently when I run feature file B, it still uses 'abc123'

1 Answer 1

1

Please do this in A - so it becomes a re-usable feature.

And request {"userId": "#(userId)"}

Now you need to call it 2 times (maybe in 2 different features and it will work):

Feature B:

call read('generateDocument.feature') { userId: 'abc456' }

Feature C:

call read('generateDocument.feature') { userId: 'abc123' }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.