karate - 如何将单个参数传递给单独的功能文件
问题描述
我在下面尝试将参数发送到单独的功能文件(通过遵循此示例),但是它没有按预期工作。
项目特征
* 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,url:https://localhost:8080/project/% 23(id) 响应:{"status":"failure","data":{"error_code":"INVALID_URL_PATTERN","message":"请检查尝试访问的 URL 是否正确"}} 在✽ .* def result = call read('delete_project.feature') (projects.feature:48)
还有一个疑问,如何通过传递 id 列表来迭代它。我在 foo 变量中有多个 id,我想为该 foo 变量中的每个可用 id 调用delete_project.feature。
* def foo = get response.data[*].id
解决方案
我认为你过于复杂的路径参数,更改为:
Given path 'project', id
并阅读这部分文档:https ://github.com/intuit/karate#rules-for-embedded-expressions
推荐阅读
- angular - Angular 测试不调用期望导致“规范没有期望”
- android - Android Firebase Analytics 不工作(卡在“运行您的应用程序以验证安装”)
- julia - 根据字典和键数组创建值数组
- javascript - 无法使用 Javascript 在 html 页面中编写
- javascript - getElementById 返回元素但随后返回 null
- react-native - 仅捕获 http 状态,而不捕获 JSON 错误响应
- jupyter - 调用 Jupyter nbconvert 时插入(python)单元格
- visual-studio-code - 相当于 Sublime Text 的 FileSync 扩展的可视代码?
- java - 将项目从一个表重新插入到另一个表的 SQL 逻辑?例如,活动记录变为非活动记录
- html - 带有 2 列的 Bootstrap 4 表单(动态)