Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Karate 空手道正则表达式给出错误-原因:不是字符串_Karate - Fatal编程技术网

Karate 空手道正则表达式给出错误-原因:不是字符串

Karate 空手道正则表达式给出错误-原因:不是字符串,karate,Karate,我编写了一个小场景,需要将json键值检查为任意整数。这是我在空手道DSL中的测试步骤: When method get * print response Then match response contains { numberOfElements: '#regex [0-9]+' } 运行时,我得到一个错误: 路径:$.numberOfElements,实际值:8,预期值:“#regex[0-9]+”,原因:不是字符串✽.然后匹配响应包含{numberOfElements:'#regex[

我编写了一个小场景,需要将json键值检查为任意整数。这是我在空手道DSL中的测试步骤:

When method get
* print response
Then match response contains { numberOfElements: '#regex [0-9]+' }
运行时,我得到一个错误:

路径:$.numberOfElements,实际值:8,预期值:“#regex[0-9]+”,原因:不是字符串✽.然后匹配响应包含{numberOfElements:'#regex[0-9]+'}


有什么问题吗?

要用
整数验证JSON值,键入的值应该是
“#number”

#numberOfElements = 8
Then match response contains { numberOfElements: '#number' }
您的方法仅用于检查类型为
string
的JSON值是否包含所有数字

#numberOfElements = '8'
Then match response contains { numberOfElements: '#regex [0-9]+' }
提及