Santoshsarma
Santoshsarma

Reputation: 5667

How to pass single param to separate feature file

I've tried below to send a param to separate feature file ( by following this example ) but, it is not working as expected.

project.feature

   * def id = '55000000005021'
   * def result = call read('delete_project.feature')

delete_project.feature

 Given path 'project', '#(id)'
 When method DELETE
 Then status 200
 Then match response.status == 'success' 

Getting below exception

com.intuit.karate.exception.KarateException: projects.feature:48 - delete_project.feature:11 - status code was: 404, expected: 200, response time: 239, url: https://localhost:8080/project/%23(id) response: {"status":"failure","data":{"error_code":"INVALID_URL_PATTERN","message":"Please check if the URL trying to access is a correct one"}} at ✽.* def result = call read('delete_project.feature') (projects.feature:48)

One more doubt, How to iterate this by passing list of ids. I've multiple id in foo variable, I would like call delete_project.feature for each id availble in that foo variable.

* def foo = get response.data[*].id

Upvotes: 1

Views: 294

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

I think you over-complicated the path params, change to:

Given path 'project', id

And read this part of the docs: https://github.com/intuit/karate#rules-for-embedded-expressions

Upvotes: 2

Related Questions