Karate For循环在空手道中的功能未按预期工作
我使用下面的代码从数组中获取JSON响应,但我只能得到12个位置。脚本正在通过,但我预计将打印218个以上的值Karate For循环在空手道中的功能未按预期工作,karate,Karate,我使用下面的代码从数组中获取JSON响应,但我只能得到12个位置。脚本正在通过,但我预计将打印218个以上的值 Feature: Verify Branches Background: For loop implementation Given url '' When method GET Then status 200 * def i = 000 * def z = response.locations[i].zip * def p = r
Feature: Verify Branches
Background: For loop implementation
Given url ''
When method GET
Then status 200
* def i = 000
* def z = response.locations[i].zip
* def p = response.locations[i].phone
* def fun =
"""
function(locations){
for (var i = 0; i < response.locations.length; i++)
{
print(i)
print('Element at Location ' + i +':' + p)
}
}
"""
Scenario: Validate the locations
Given url ''
When method GET
Then status 200
* call fun z
* print z.length
功能:验证分支
背景:用于循环实现
给定url“”
当方法得到
然后状态200
*DEFI=000
*def z=response.locations[i].zip
*def p=响应。位置[i]。电话
*def fun=
"""
功能(位置){
对于(变量i=0;i
z、 长度应该是218,但z是218,p是10,p是12。请使用空手道中的
匹配每个。您永远不需要以编程方式来完成它
* def data = { foo: [{ bar: 1, baz: 'a' }, { bar: 2, baz: 'b' }, { bar: 3, baz: 'c' }]}
* match each data.foo == { bar: '#number', baz: '#string' }