Calling a scenario in another feature file by scenario name

柔情痞子 提交于 2021-02-15 07:33:35

问题


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.


回答1:


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')


来源:https://stackoverflow.com/questions/59970840/calling-a-scenario-in-another-feature-file-by-scenario-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!