karatelabs / karate

Test Automation Made Simple
https://karatelabs.github.io/karate
MIT License
8.25k stars 1.94k forks source link

Loading a file with csv type leads to java.lang.NullPointerException #1279

Closed digoo closed 4 years ago

digoo commented 4 years ago

I was trying to load a csv file with the csv type and I'm receiving NPE, I have attached the project for debug, but:

Scenario: Working
  * text foo =
  """
    test_id,offer_name,affiliate_name,advertiser_name
    1,autoCsvOffer1,autoCsvAffiliate1,autoCsvAdvertiser1
    2,autoCsvOffer2,autoCsvAffiliate2,autoCsvAdvertiser2
    3,autoCsvOffer3,autoCsvAffiliate3,autoCsvAdvertiser3
    4,autoCsvOffer4,autoCsvAffiliate4,autoCsvAdvertiser4
    5,autoCsvOffer5,autoCsvAffiliate5,autoCsvAdvertiser5
  """
  * csv bar = foo
  * print bar
Scenario: Failing
  * print csvFile
  * csv csvFile = read('this:generalNamesData.csv')
  * print csvFile

It must be related to read function.

anyToCsvNPE.zip

ptrthomas commented 4 years ago

@digoo sorry, csv is for converting strings to JSON, for example:

  * csv csvFile = karate.readAsString('this:generalNamesData.csv')

if you think something needs to be changed, please contribute code (or docs)