Karate-遍历数组并为每个值调用rest api



场景:

* def Test_assignment_type = 'ALL'
* def TEST_NODE_ID = '123455667'
* def list = [ '123', '1234', '12345' ]
* def gId_list = karate.mapWithKey(list, 'HOOK_TEST_LOCATION_GID')  
* callonce read('classpath:hook/delete-assignments-hook.feature') {HOOK_TEST_LOCATION_ID: "#(TEST_NODE_ID)", HOOK_TEST_ASSIGNMENT_TYPE: "#(Test_assignment_type)"}

delete-assignments-hook。功能:

场景:

* Given path '/nodes/'+HOOK_TEST_LOCATION_ID+'/locations/'+HOOK_TEST_LOCATION_GID+'/assignments'
* And param assignmentType = HOOK_TEST_ASSIGNMENT_TYPE
* When method delete
* Then assert responseStatus == 204  || responseStatus == 404

如何在delete-assignments-hook.feature中传递gId_list,以便为列表中的每个值运行delete api。

只需从一个简单的例子开始并研究它。下面将使用一个名为id的参数进行3次调用。同时阅读文档:https://github.com/karatelabs/karate#data-驱动特征

Feature:
Scenario:
* def array = [1, 2, 3]
* def data = karate.mapWithKey(array, 'id')
* call read('@called') data
@ignore @called
Scenario:
* url 'https://httpbin.org/anything'
* param id = id
* method get