Loops 如何在空手道功能中循环数组值

Loops 如何在空手道功能中循环数组值,loops,automation,bdd,karate,Loops,Automation,Bdd,Karate,我试图在空手道功能文件中循环数组值。 在Feature1.feature-Scenario1中,数组[“UUID1”、“UUID2”、“UUID3”]中有一些值,我想调用服务的另一个功能文件(Feature2.feature)(具有调用删除端点的代码) 特点2.特点: @ignore Feature: Delete Background: * url baseUrl * headers {content-type:'application/json'} Scen

我试图在空手道功能文件中循环数组值。 在Feature1.feature-Scenario1中,数组[“UUID1”、“UUID2”、“UUID3”]中有一些值,我想调用服务的另一个功能文件(Feature2.feature)(具有调用删除端点的代码)

特点2.特点:

 @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?

如果您有一个原语数组,则需要在执行“循环调用”之前将其转换为JSON对象数组。请参阅有关空手道.mapWithKey()的文档。:

这样做:

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

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

当然,如果需要,请阅读
呼叫
的文档:

请检查以下答案:这就像一个符咒。这正是我想做的。谢谢@peter-thomas@SahilDua太好了:)请看这个: