How to run a Cucumber-JVM feature file from the command line

◇◆丶佛笑我妖孽 提交于 2019-12-24 16:47:44

问题


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.


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/23324507/how-to-run-a-cucumber-jvm-feature-file-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!