空手道正则表达式给出错误 - 原因:不是字符串
Karate regex giving error - reason: not a string
我写了一个小场景,我需要检查 json 键值是否为任何整数。所以这是我在空手道 DSL 中的测试步骤:
When method get
* print response
Then match response contains { numberOfElements: '#regex [0-9]+' }
当 运行 时,我得到错误:
path: $.numberOfElements, actual: 8, expected: '#regex [0-9]+', reason: not a string at ✽.Then match response contains { numberOfElements: '#regex [0-9]+' }
有什么想法是错误的吗?
为了验证 integer
类型的 JSON 值,它应该是 '#number'
#numberOfElements = 8
Then match response contains { numberOfElements: '#number' }
您的方法只会检查 string
类型的 JSON 值是否包含所有数字。
#numberOfElements = '8'
Then match response contains { numberOfElements: '#regex [0-9]+' }
我写了一个小场景,我需要检查 json 键值是否为任何整数。所以这是我在空手道 DSL 中的测试步骤:
When method get
* print response
Then match response contains { numberOfElements: '#regex [0-9]+' }
当 运行 时,我得到错误:
path: $.numberOfElements, actual: 8, expected: '#regex [0-9]+', reason: not a string at ✽.Then match response contains { numberOfElements: '#regex [0-9]+' }
有什么想法是错误的吗?
为了验证 integer
类型的 JSON 值,它应该是 '#number'
#numberOfElements = 8
Then match response contains { numberOfElements: '#number' }
您的方法只会检查 string
类型的 JSON 值是否包含所有数字。
#numberOfElements = '8'
Then match response contains { numberOfElements: '#regex [0-9]+' }