2

Hi I have the following feature file:

checkout.feature

  Scenario: checkout items in basket 
    * call read('classpath:login.feature@[call by scenario name]')
    Given path '/checkout'
    And request {"items":{"biscuits": 1,"apples": 2}}
    When method post
    Then status 200

Before checking out the items in the basket, I would like to call the login.feature by scenario name (log into app with credentials), without the use of a tag. Could you please tell me the syntax in order to do so?

login.feature

  Scenario: log into app with credentials 
    Given path '/login'
    And request {"userDetails":{"userName": 1,"apples": 2}}
    When method post
    Then status 200

I have read https://github.com/intuit/karate#call-tag-selector but can't seem to get it to work.

zwanchi101
  • 181
  • 3
  • 14

2 Answers2

2

Because you don't have a tag. Add this line above the Scenario in login.feature:

@foo

And then you just do this:

* call read('classpath:login.feature@foo')
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Hey Peter - I understand that it's possible to reference a scenario via tag. I wanted to know if there was a way to reference the scenario via scenario name? – zwanchi101 Jan 29 '20 at 16:51
  • @zwanchi101 no, we will never support it for `call` because names can have spaces and special characters – Peter Thomas Jan 29 '20 at 16:57
  • @zwanchi101 : Did u get any solution for it am too stuck on the same i need to call with scenario name or scenario description, please add ur comments if u have any solution – Dinesh Tejaj May 18 '22 at 12:57
0

Feature1

@exampleTag
Scenario: Name

Feature2

def result = call read('classpath:pathFromSourceRoot/Feature1.feature@exampleTag')
toyota Supra
  • 3,181
  • 4
  • 15
  • 19