如何在字符串数组上为 "any array item starts with" 做一个空手道匹配器?
How can I do a Karate matcher for "any array item starts with" on a String array?
假设我的“工作流程结果”等于:
["START","Success : <0_4726310526.1228950033456.WEBSERVICES@random>","END"]
如果我要编写空手道匹配器来验证该列表中的任何项目“以子字符串 'Success' 开头”,那么我将如何编写匹配器?
这是我尝试过的方法,但无法正常工作:
* def starts_with = function(x){ return x.startsWith('Success') }
* match result_arr contains any ["# starts_with(_)"]
无法在空手道文档中找到答案。
给你:
* def response = ["START","Success : <0_4726310526.1228950033456.WEBSERVICES@random>","END"]
* def fun = function(x){ return x.startsWith('Success') }
* def temp = karate.filter(response, fun)
* assert temp.length > 0
假设我的“工作流程结果”等于:
["START","Success : <0_4726310526.1228950033456.WEBSERVICES@random>","END"]
如果我要编写空手道匹配器来验证该列表中的任何项目“以子字符串 'Success' 开头”,那么我将如何编写匹配器?
这是我尝试过的方法,但无法正常工作:
* def starts_with = function(x){ return x.startsWith('Success') }
* match result_arr contains any ["# starts_with(_)"]
无法在空手道文档中找到答案。
给你:
* def response = ["START","Success : <0_4726310526.1228950033456.WEBSERVICES@random>","END"]
* def fun = function(x){ return x.startsWith('Success') }
* def temp = karate.filter(response, fun)
* assert temp.length > 0