如何将单个参数传递给单独的功能文件

时间:2019-03-06 05:37:27

标签: karate

我在下面尝试过将参数发送到单独的功能文件中(通过遵循this example),但是,该参数无法正常工作。

project.feature

   * def id = '55000000005021'
   * def result = call read('delete_project.feature')

delete_project.feature

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

摆脱异常

  

com.intuit.karate.exception.KarateException:projects.feature:48-   delete_project.feature:11-状态代码为:404,预期:200,   响应时间:239,网址:https://localhost:8080/project/%23(id)   响应:   {“状态”:“失败”,“数据”:{“错误代码”:“ INVALID_URL_PATTERN”,“消息”:“请   检查要访问的URL是否正确,请在✽。* def   结果=调用read('delete_project.feature')(projects.feature:48)

另一个疑问,如何通过传递ID列表来对此进行迭代。我在foo变量中有多个ID,我想为该foo变量中的每个ID调用 delete_project.feature

* def foo = get response.data[*].id

1 个答案:

答案 0 :(得分:2)

我认为您使路径参数过于复杂,请更改为:

Given path 'project', id

并阅读文档的这一部分:https://github.com/intuit/karate#rules-for-embedded-expressions