如何在空手道特征中循环数组值

问题描述 投票:1回答:1

我正在尝试遍历空手道特征文件中的数组值。在Feature1.feature-Scenario1中,数组[“ UUID1”,“ UUID2”,“ UUID3”]中有一些值,并且我想调用另一个功能文件(Feature2.feature)(具有用于调用DELETE端点的代码) )的服务

Feature2.feature:

 @ignore

Feature: Delete

  Background:

    * url baseUrl
    * headers {content-type:'application/json'}

  Scenario: Delete Test Assets

    Given headers {uid: '#(UId)', cid:'#(CId)'}
    And path 'type', Type, 'id', AssetId
    When method delete
    Then status 204

我应该对Feature1.feature使用哪种方法来循环调用Feature2.feature?

loops automation bdd karate
1个回答
0
投票
也是这样:

* def data = ["UUID1","UUID2","UUID3"] * def data = karate.mapWithKey(data, 'uid') * call read('second.feature') data

并且在second.feature中:

* headers { uid: '#(uid)' }

当然,如果需要,请阅读call的文档:https://github.com/intuit/karate#data-driven-features

© www.soinside.com 2019 - 2024. All rights reserved.