1

The standard for csv files being used by our clients uses ; as delimiters and it appears that Karate does not allow for this. I would not like to change the delimiters in the file prior to running the Karate tests as this defeats the purpose of an automated test.

Feature: Serverless

  Background:
    * text data =
    """
    name;unit;cost
    Cheese;ea;34.50
    Cake;ea;55.54
    Chicken;kg;
    Cement;ml;4.32
    """
    * csv data = data
    * def isValid = function(x){ return (x.name && x.unit) ? x.cost.length != 0 : true }

  Scenario Outline:
    * assert isValid(__row)

    Examples:
      | data |

The test returns 4 valid responses even though one of them fails. If you run the same feature using , 's then it works correctly. Is this a limitation in the tool or is there an alternative way of handling this?

1 Answers1

0

This is a rare requirement so I strongly suggest that you contribute code to Karate (or influence someone who can).

Karate does the CSV reading as a convenience and there is a 3rd party library behind the scenes. You can also consider writing a Java utility (one time) to read any kind of file, refer: https://stackoverflow.com/a/47954946/143475

Else please consider this as not supported by Karate.

EDIT: note that there is a karate.extractAll() method that may allow you to scrape data out of a string in simple cases

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