空手道 DSL_GET 每个参数有两个值。验证它们是否包含在响应中
karate DSL_GET with two values per parameter. Validate that they are contained in the response
这是我的特色:
Feature: test
Background:
Given url baseUrl + pathApiSurvey
Scenario: filtro varios valores
Given path id_survey_erc,'controls',69, 'evidences'
And param nombre = 'postman,extorsion'
When method Get
* print response
Then status 200
And match response.status == 'success'
And match response.data !contains null
And match each response.id[*].nombre contains any 'postman','extorsion'
在我正在测试的 api 中,您可以通过以逗号分隔的多个值来筛选参数。通过我拨打的电话,它向我显示了“名称”包含“邮递员”或“勒索”的记录
响应示例:
{
"status": "success",
"code": 200,
"current_page": 1,
"data": [
{
"id": 1,
"id_evidencia": 1,
"id_encuesta": 43,
"identificador": 2,
"tipo": 15,
"periodicidad": 1,
"fecha": 1633310022,
"activa": 1,
"nombre": "prueba evidencia modificada por postman",
"evidencia_modificada": 1
},
{
"id": 2,
"id_evidencia": 2,
"id_encuesta": 43,
"identificador": 2,
"tipo": 16,
"descripcion": null,
"ubicacion": null,
"size_evidencia": null,
"periodicidad": null,
"fecha": null,
"activa": 1,
"nombre": "evidencia 2 extorsion por amenaza C1",
"evidencia_modificada": 1
}
]
}
我无法通过组合条件逻辑和匹配包含来验证。有人可以帮帮我吗。
谢谢!
这一行是一个解决方案:
* match each response..nombre == "#? _.includes('postman') || _.includes('extorsion')"
如果需要了解其工作原理,请阅读文档,另请参阅:
这是我的特色:
Feature: test
Background:
Given url baseUrl + pathApiSurvey
Scenario: filtro varios valores
Given path id_survey_erc,'controls',69, 'evidences'
And param nombre = 'postman,extorsion'
When method Get
* print response
Then status 200
And match response.status == 'success'
And match response.data !contains null
And match each response.id[*].nombre contains any 'postman','extorsion'
在我正在测试的 api 中,您可以通过以逗号分隔的多个值来筛选参数。通过我拨打的电话,它向我显示了“名称”包含“邮递员”或“勒索”的记录
响应示例:
{
"status": "success",
"code": 200,
"current_page": 1,
"data": [
{
"id": 1,
"id_evidencia": 1,
"id_encuesta": 43,
"identificador": 2,
"tipo": 15,
"periodicidad": 1,
"fecha": 1633310022,
"activa": 1,
"nombre": "prueba evidencia modificada por postman",
"evidencia_modificada": 1
},
{
"id": 2,
"id_evidencia": 2,
"id_encuesta": 43,
"identificador": 2,
"tipo": 16,
"descripcion": null,
"ubicacion": null,
"size_evidencia": null,
"periodicidad": null,
"fecha": null,
"activa": 1,
"nombre": "evidencia 2 extorsion por amenaza C1",
"evidencia_modificada": 1
}
]
}
我无法通过组合条件逻辑和匹配包含来验证。有人可以帮帮我吗。 谢谢!
这一行是一个解决方案:
* match each response..nombre == "#? _.includes('postman') || _.includes('extorsion')"
如果需要了解其工作原理,请阅读文档,另请参阅: