automationkarate

Run examples Karate Framework


I am currently facing a problem when using scenario outline. That is when I want to run a testcase in Scenario Outline/ Examples, I cannot run it alone but it runs all scenarios in examples. It takes many time. Is there any way to handle this case?


Solution

  • Yes you can handle this by using tags to filter what rows should run from the Scenario Outline/Examples table, please refer to the following Karate documentation - https://github.com/karatelabs/karate#tags-and-examples

    A little-known capability of the Gherkin syntax is to be able to tag even specific rows in a bunch of examples ! You have to repeat the Examples section for each tag. The example below combines this with the advanced features described above.

    Scenario Outline: examples partitioned by tag
    * def vals = karate.tagValues
    * match vals.region[0] == expected
    
      @region=US
      Examples:
        | expected |
        | US       |
    
      @region=GB
      Examples:
        | expected |
        | GB       |
    

    Note that this will require you to add two/multiple Example headers to your Scenario Outline.