Search code examples
karate

Karate API Testing Running Tests from Command Line


I see this example

mvn test -Dcucumber.options="--tags ~@ignore" -Dtest=AnimalsTest

How do i pass feature file name directly in command line.

Something like :

mvn test -Dcucumber.options="--features=classpath:com/test/graphql/features/Scenario1.feature" -Dtest=com.graphql.ApiTest;

Solution

  • Since you are using a Java JUnit runner in this case, add a @CucumberOptions annotation to the JUnit class and that is the recommended way to do what you want.

    @RunWith(Karate.class)
    @CucumberOptions(features = "classpath:com/test/graphql/features/Scenario1.feature")
    public class AnimalsTest {
        
    }
    

    EDIT - Karate no longer uses annotations for running tests, use the Java Runner API: https://github.com/karatelabs/karate#parallel-execution