Reputation: 11
I am tried scenario outline with inbuilt table examples within scenario and it worked well. But ask from my team is to have more number of examples using external excel sheet. So instead of Excel and trying to have it as CSV file for Test data. But tried using csv file with the examples available in Github and failed with those examples. As am not a programmer not sure on the mistake I made. Below is the scenario Outline,
Feature: Feature1
Background:
* url ''
* configure logPrettyRequest = true
* configure logPrettyResponse = true
Scenario Outline: 1
* def look= read('../utils/look.xml')
* replace look
| token | value |
| @@number@@ | < number> |
| @@country@@ |< country>|
Given url 'baseurl'
And request look
When method post
Then status 200
Examples:
|read('name.csv')|
But while running this script console logs as :
0 Scenarios
0 Steps
0m0.000s
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.78 s - [INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
CSV file contents:name.csv
number,country
895201301,173
Issue: No scenarios identified as part of this run
Please suggest way to use CSV file for Test data under scenario Outline of Karate.
Upvotes: 1
Views: 926
Reputation: 153
I faced a similar issue, two points, can you try to add single quotes to all data in your csv file if not already done. Intead of 'replace' can you try to use set method to set the values on the fly. Please let me know if this helps
Upvotes: 1
Reputation: 1096
Couple of issues: The extra space in front of the number and country placeholders has to be removed. Also, the placeholders should be enclosed in quotes.
Sample Code:
Feature: Feature1
Background:
* url ''
* configure logPrettyRequest = false
* configure logPrettyResponse = false
Scenario Outline: <number>,<country>
* def look = "@@number@@,@@country@@"
* replace look
| token | value |
| @@number@@ | '<number>' |
| @@country@@ | '<country>' |
* print look
Examples:
| read('name.csv') |
Upvotes: 1