I am looking for a way to use data driven in combination with an external request file.
So my feature file looks like this:
Feature: EPOS UNIT test - GetSpendingLimit
Background:
* url 'http://xxx-yyy-zzz'
* def GetSpendingLimit_request = read('classpath:examples/EPOS/request/GetSpendingLimit-dd-request.xml')
* def GetSpendingLimit_data = read('classpath:examples/EPOS/data/GetSpendingLimit.csv')
Scenario Outline: GetSpendingLimit External Request Datadriven
Given request GetSpendingLimit_request
When soap action 'TotalAmount'
Then status 200
# define a variable to check the response
* def total_amount = /Envelope/Body/GetSpendingLimitResponse/spendingLimit/totalAmount
# to print the result to the report
* print '\nTotal Amount is: ', total_amount
Examples:
|read('classpath:examples/EPOS/data/GetSpendingLimit.csv')|
And my request looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://xxx-yyy-zzz/GetSpendingLimit/Request" xmlns:com="http://xxx-yyy-zzz/Common" xmlns:ser="http://xxx-yyy-zzz/Common/ServiceContext">
<soapenv:Header/>
<soapenv:Body>
<req:GetSpendingLimitRequest>
<ser:productServiceContext>
<ser:conversationId>GetSpendingLimit_1_1</ser:conversationId>
<ser:deviceTypeId>1</ser:deviceTypeId>
<ser:entityId>nl</ser:entityId>
<ser:product>
<ser:id><product-id></ser:id>
</ser:product>
<ser:user>
<ser:id><user-id></ser:id>
</ser:user>
</ser:productServiceContext>
</req:GetSpendingLimitRequest>
</soapenv:Body>
</soapenv:Envelope>
Notice that I have added product-id and user-id as variable which should be replaced by data driven input from the csv. But I get the following error:
[Fatal Error] :10:43: The element type "product-id" must be terminated by the matching end-tag "</product-id>".
11:35:18.404 [main] ERROR com.intuit.karate - src/test/java/examples/EPOS/GetSpendingLimit-external-request-datadriven.feature:5
* def GetSpendingLimit_request = read('classpath:examples/EPOS/request/GetSpendingLimit-dd-request.xml')
js failed:
>>>>
01: read('classpath:examples/EPOS/request/GetSpendingLimit-dd-request.xml')
<<<<
I have tried the request in the feature file and this works fine. But the request in external file fails.