1

I have a Karate Test scenario where I need to execute certain Test statements based on a condition i.e Environment .If karate.env = QA then a particular statement should not execute. in all other cases that statement should execute.

Example:

@Search
 Scenario Outline: Verify the search Service Response for Search keyword 

Given url baseSeviceURL
And path '/searchService'
And params { searchTerm: '<SearchTerm>'}
And method get
And status 200
Then assert response.productDetails.count() > 1

Examples:
|SearchTerm |
| book      |

*Here I want to execute the statement - Then assert response.productDetails.count() > 1; only if karate.env == QA, which I am setting through Maven as a command line parameter.

The Gherkin syntax does not allow the if else logic to be written in Feature files ... is there any karate Library methods for achieving this ..

Muldec
  • 4,641
  • 1
  • 25
  • 44
Damascus
  • 19
  • 6
  • Read the docs for conditional logic: https://github.com/intuit/karate#conditional-logic. Normally people use tags for this. Other ideas here: https://stackoverflow.com/a/57206396/143475 – Peter Thomas Oct 02 '19 at 13:34

0 Answers0