Search code examples
cucumber-jvmkarate

Karate: how to pass dynamic path parameters?


Suppose I have test scenario with exact same requirements but one path variable change as follows:

Scenario: Some scenario

Given  path /mypath/param1
When method get
Then status 200

I need to run the same test for /mypath/param2, /mypath/param3 as well.

Is there a simpler way to do it without requiring to separate the feature into a separate file and using data driven test?


Solution

  • Yes, use the Scenario Outline which is a standard Cucumber pattern.

    Scenario Outline: Some scenario
    
    Given  path /mypath/<param>
    When method get
    Then status 200
    
    Examples:
    | param |
    | foo   |
    | bar   |