karate - 在空手道测试的路径中使用逗号
问题描述
使用以下测试用例
Background:
* callonce read('auth.feature')
* url java.lang.System.getenv('TEST_URL')
Scenario: Call the file endpoint without authorization
Given path 'files/123695_11,8'
When method get
Then status 401
我收到有关引号不匹配的解析器错误。原因可能是“路径”被逗号混淆了,因为它也可以用来表示子路径。
我想过只是更改,
to %2C
,但随后空手道使用%
编码 to调用 URL %25
,导致错误的 URL'files/123695_11%252C8'
解码为字面意思'files/123695_11%2C8'
。
我怎样才能使它正常工作?
解决方案
最简单的选项,合并到url
:
* url 'https://httpbin.org/anything/files/123695_11,8'
* method get
我知道你可能想在后台“重用”东西,所以使用变量:
Background:
* def baseUrl = 'https://httpbin.org/anything'
Scenario:
* url baseUrl + '/files/123695_11,8'
* method get
哈克解决方法:
* url 'https://httpbin.org/anything'
* def temp = 'files/123695_11,8'
* path temp
* method get
推荐阅读
- css - 如何使表格行可点击并通过在视觉上将其置于前面来突出显示它?
- java - OOP,MVC,(Java)中的数据库调用混淆
- r - 当我尝试在 swirlify 中运行测试时,包含非 ascii 字符的课程会产生错误
- r - 将 arules::inspect 的输出捕获为 data.frame
- angular - 注入的服务不起作用
- javascript - 使用 openlayers 动态添加 GPX
- javascript - 使用异步函数调用创建新的承诺是不好的做法吗?
- python - Python 分析、导入(特别是 __init__)似乎花费的时间最多
- node.js - 无法使用 nginx 显示域名而不是 IP
- react-native - 让 Epubjs-rn 工作