citrusframework / yaks

YAKS is a platform to enable Cloud Native BDD testing on Kubernetes
Apache License 2.0
82 stars 28 forks source link

support xml body in http steps (message validator) #338

Closed grebrov closed 3 years ago

grebrov commented 3 years ago

When "testing" http request with xml content I get the error:

com.consol.citrus.exceptions.TestCaseFailedException: Failed to find proper message validator for message

Doing the same request with json body works.

Can be reproduced with this feature file (the api supports xml and json, depending on the header):

`Feature: http request with xml-body

Scenario: xml
    Given URL: http://api.nbp.pl
    Given HTTP request headers
        | Accept | application/xml |
        | Content-Type | text/xml |

    When send GET /api/exchangerates/tables/A/
    Then receive HTTP 200

Scenario: json
    Given URL: http://api.nbp.pl
    Given HTTP request headers
        | Accept | application/json |
        | Content-Type | text/json |

    When send GET /api/exchangerates/tables/A/
    Then receive HTTP 200`

First scenario fails with the above error, second is successful

christophd commented 3 years ago

the XML message validator is not part of the default YAKS runtime. You will have to add it as an explicit dependency to the test runtime.

You can do this via yaks-config.yaml or using the require Cucumber tag in your feature file.

yaks-config.yaml

config:
  runtime:
    settings:
      dependencies:
        - groupId: com.consol.citrus
          artifactId: citrus-validation-xml
          version: "@citrus.version@"

require tag_

@require('com.consol.citrus:citrus-validation-xml:@citrus.version@')
Feature: Foo

  Scenario: xml
  ...
grebrov commented 3 years ago

Dear Christoph, thank you very much and sorry, that I didn't find out myself. Works perfectly