断言时出错
field1
是数据库中的值,我想将它们与field2
(来自响应xml的值)进行匹配
* def field1 = get TABLE[*].COLUMN
Field2是以下操作的结果
* def field2 = get Response SOME_XML_XPATH
它可能包含值列表的单个值,例如
field2 = 19.2
或field2 = ["188.3","281.11"]
问题是当我尝试比较两个字段时,它们都像列表一样
field1 = [1850, 700, 30] field2 = ["1850.0","30.0","700.0"]
为了解决这个问题,我使用了以下代码,
* def field1 = [1850, 700, 30]
* def field2 = ["1850.0","30.0","700.0"]
* def field3 = karate.map(field2, function(x){ return ~~x })
* match field1 contains only field3
这很好,但是,当field2
是单个值,并且我想将其与field1
匹配时,我得到了错误提示
无法将java.lang.String转换为java.util.List
答案 0 :(得分:0)
请阅读文档。有一种叫做contains
的东西:https://github.com/intuit/karate#match-contains
* def field1 = [1850, 700, 30]
* def field2 = "30.0"
* def field2 = ~~field2
* match field1 contains field2