Search code examples
karate

How to run a single scenario in Karate?


To test a specific feature in karate I run:

mvn test -Dkarate.options="classpath:myfeature.feature"

Is there a way to run a single scenario defined into a feature?


Solution

  • Yes, you can via tags: https://github.com/intuit/karate#tags

    Also note that you can run a scenario by name, for e.g. if the name is "first":

    mvn test -Dkarate.options="classpath:myfeature.feature --name ^first$" 
    

    And if you use IntelliJ - you can right click and do the above.

    EDIT: Karate now supports being able to use a line-number, for e.g. some.feature:42 so it will invoke only the Scenario or outline Example on line 42 - this is designed only for IDE-s and developer mode, use a tag for maintainability.