如何将单个参数传递给单独的特征文件
How to pass single param to separate feature file
我在下面尝试将参数发送到单独的功能文件(通过遵循 this example )但是,它没有按预期工作。
project.feature
* def id = '55000000005021'
* def result = call read('delete_project.feature')
删除_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 - status code was: 404, expected: 200,
response time: 239, url: https://localhost:8080/project/%23(id)
response:
{"status":"failure","data":{"error_code":"INVALID_URL_PATTERN","message":"Please
check if the URL trying to access is a correct one"}} at ✽.* 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
我在下面尝试将参数发送到单独的功能文件(通过遵循 this example )但是,它没有按预期工作。
project.feature
* def id = '55000000005021'
* def result = call read('delete_project.feature')
删除_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 - status code was: 404, expected: 200, response time: 239, url: https://localhost:8080/project/%23(id) response: {"status":"failure","data":{"error_code":"INVALID_URL_PATTERN","message":"Please check if the URL trying to access is a correct one"}} at ✽.* 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