1

This is my feature:

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'

In the api I am testing you can filter on a parameter by multiple values separated by commas. With the call I make, it shows me the records whose "name" contains "postman" or "extorsion"

Example response:

{
    "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
        }
    ]
}

I can't validate by combining Conditional Logic and match contains. Can somebody help me. Thanks!

1 Answers1

0

This one line is a solution:

* match each response..nombre == "#? _.includes('postman') || _.includes('extorsion')"

Please read the docs if needed to understand how it works, also refer: https://stackoverflow.com/a/50350442/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248