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

问题描述 投票:0回答:2

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

结账功能

  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(使用凭据登录应用程序),而不使用标签。您能告诉我这样做的语法吗?

登录功能

  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但似乎无法让它工作。

karate reusability
2个回答
2
投票

因为你没有标签。在

Scenario
中的
login.feature
上方添加此行:

@foo

然后你就这样做:

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

0
投票

特点1 @example标签 场景:名字

功能2

  • def 结果 = 调用 read('classpath:pathFromSourceRoot/Feature1.feature@exampleTag')
© www.soinside.com 2019 - 2024. All rights reserved.