1

I would like to compare the text file, however the API is returning application/octet-stream which I cannot change currently. That's why karate probably tries to compare the binary and test. That means this:

    Given path '/download/testing/'+fileId
    When method get
    Then status 200
    And match response == read('../files/test.txt')

leads to:

match failed: EQUALS
$ | data types don't match (LIST:STRING)
  [116,101,115,116,105,110,103]
  'testing'

The file test.txt contains just testing. I cannot find the way how to convert string to byte array. I could use probably java function, but at first I would like to find out if there is some built-in function.

Mejmo
  • 2,363
  • 9
  • 35
  • 54

1 Answers1

0

You can do type conversions: https://github.com/karatelabs/karate#type-conversion

So this will convert a binary response into text:

* string response = response

That should get you going. The reverse is also possible.

For completeness, note that the responseBytes variable will always contain a copy of the response, but as a byte-array.

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