1

I have a file with file extension .feature. HOw do run this from the command line?

In order to make a batch file for each feature. I am using Cucumber-JVM with Java and Selenium.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dhussein
  • 29
  • 1
  • 5

3 Answers3

3

Cucumber-JVM is based on JUnit so its just like running any unit tests from the command line

java -cp /path/to/junit.jar org.junit.runner.JUnitCore [test class name]

where test class name is annotated with @CucumberOptions whose features refer to the feature file. If youre using Maven you could use

mvn test
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • this error keeps displaying when i attempt to run the line you provided JUnit version 4.4 Could not find class: test.feature Time: 0 OK (0 tests) – Dhussein Apr 28 '14 at 10:09
  • add the location of your test class to the classpath – Reimeus Apr 28 '14 at 11:53
1

If you are using Maven, you can run your .feature file this way:

mvn -Dcucumber.options="from/the/root/of/module/to/the/feature/MyFeature.feature" test

This will override the @CucumberOptions in the test runner class.

0

You can run any test runner or override default test runner by using the command line below. This means you only want to run the test named SmokeTestRunner. By the way, you are free to set surefire plugin in your pom.xml any way. For example, you can set up your surefire plugin in your pom.xml to run the regression test named RegressionTestRunner. It doesn't matter.

mvn -Dtest=**/SmokeTestRunner.java test

Your SmokeTestRunner java file should look like this. ->

@CucumberOptions(
features = "src/test/resources/features/Smoke.feature",
glue = {"stepdefinitions", "hooks"},
tags = "@chrome", // It runs only scenarios tagged with "@chrome"
plugin = {"pretty"/*you can add more cucumber plugins here if you want.*/},
monochrome = true)
public class SmokeTestRunner extends AbstractTestNGCucumberTests {}

For more details, have a look at the maven surefire plugin docs. (https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html)

Orçun
  • 11
  • 2