通过场景名称调用另一个特征文件中的场景

Calling a scenario in another feature file by scenario name

您好,我有以下功能文件:

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

在检查购物篮中的商品之前,我想通过场景名称调用 login.feature(使用凭据登录应用程序),而不使用标签。你能告诉我这样做的语法吗?

login.feature

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

我已阅读 https://github.com/intuit/karate#call-tag-selector 但似乎无法正常工作。

因为你没有标签。在 login.feature 中的 Scenario 上方添加此行:

@foo

然后你就这样做:

* call read('classpath:login.feature@foo')