3

I am writing test cases for my API testing using Karate.

When I try to upload files on my computer, I use Scenario Outline because I have dynamically changing number of files on the disk under a specific folder. For this reason, I am using CSV file that contains URL and fileName the rows. My csv file looks like below(data.csv):

|URL|fileName|
|http://localhost:8080/VIN/input/telemetry/division_vin_2019_01_12_22_56_01_telemetry.json|telemetry_19_01_12_22_56_01.json.bz2|
|http://localhost:8080/VIN/input/media/vinId_1012_2019_01_12_22_55_55_10_c4.jpeg|c4_wm.jpeg|
|http://localhost:8080/VIN/input/media/vinId_1012_2019_01_12_22_55_55_10_c5.mp4|c5_wm.mp4|
|http://localhost:8080/VIN/input/media/vinId_1012_2019_01_12_22_55_55.json.bz2|media_19_01_12_22_55_59.json.bz2|

I will also attach the screenshot of the csv file in case it is not clear formatted in this post.

And I have Feature File runs my test case like below:

Feature: scenario outline using a dynamic table
  from a csv file

  Scenario Outline:
    * url <URL>
    * multipart file myFile = { read: '<fileName>', filename: '<fileName>', contentType: 'multipart/form-data' }
    * multipart field message = 'hello world'
    * method post
    * status 200
    Examples:
      | read('data.csv') |

Feature File

When I run this feature file, it does not run the scenarios even the csv file has 4 rows.

The output comes like below on console:

0 Scenarios 0 Steps 0m0.000s

Which is it does not recognize the csv file and no data is passed.

Please help me to figure it out..

data.csv File Screenshot

1 Answers1

1

You should use Example header variables same as that of your CSV column header

Column names in your CSV's are URL, fileName but you have used <link>, <file> in your script.

Which is supposed to be <URL> and <fileName>

try,

Feature: scenario outline using a dynamic table
  from a csv file

  Scenario Outline:
    * url <URL>
    * multipart file myFile = { read: '<fileName>', filename: '<fileName>', contentType: 'multipart/form-data' }
    * multipart field message = 'hello world'
    * method post
    * status 200
    Examples:
      | read('data.csv') |

refer examples from Karate Demo

Dynamic CSV feature

Examples CSV

Babu Sekaran
  • 4,129
  • 1
  • 9
  • 20