How to iterate list of params through separate fea

2019-07-16 14:11发布

问题:

How to iterate this by passing a list of ids. I've multiple ids in foo variable, I would like call delete_project.feature for each id available in that foo variable.

project.feature

* def foo = get response.data[*].id
* def del = call read('delete_project.feature') 

delete_project.feature

 Given path 'project', id
 When method DELETE
 Then status 200
 Then match response.status == 'success'

回答1:

By passing list of id's as a input to your feature you can actually make the call iterate feature that many times.

* def foo = get response.data[*].id
* def createId = function(x) {return {"id" :x}} 
* def ids = karate.map(foo,createId) 
* def del = call read('delete_project.feature') ids

Refer data driven feature in karate



标签: karate