java cucumber.api.cli.main命令行用法

时间:2016-10-24 10:58:04

标签: java class command-line junit cucumber-jvm

尝试进行一些自动化测试。我在命令行而不是eclipse中执行黄瓜项目时遇到了困难。我知道我们可以通过cucumber.api.cli.main类(cucumber-core.jar)来完成它,但我不知道如何从命令行选项中使用它。

试图执行Junit的命令:

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore C:/Users/path/workspace/CucumberConcept/src/ cucumber.CucumberRunner

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar;C:/Users/path/workspace/CucumberConcept/src/ org.junit.runner.JUnitCore cucumber.CucumberRunner

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberConcept.src.cucumber.CucumberRunner

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore cucumber.CucumberRunner.CucumberRunner

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner.CucumberRunner

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner CucumberRunner

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner.java CucumberRunner

java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner

Jar文件位置

 C:/users/path/lib/cucumber-core-1.2.4.jar

项目结构:

CucumberConcept
 -src
   -cucumber(package)
      -CucumberRunner.java
     -Features(package)
       -Stepdefinitions.java
       -myfeature.feature

CucumberRunner.java代码

package cucumber;

    import org.junit.runner.RunWith;

    import cucumber.api.junit.*;
    import cucumber.api.CucumberOptions;

    @RunWith(Cucumber.class)
    @CucumberOptions(
            plugin = {"pretty","json:target/json/output.json","html:target/html/"},
            features = {"src/cucumber/"}
            )
    public class CucumberRunner {
    }

1 个答案:

答案 0 :(得分:0)

您需要在调用中引用CucumberRunner,而不是您希望Cucumber处理的要素文件的位置。

要访问Cucumber CLI,您必须运行Main类,而不是JUnitCore

所以,从src我希望

java -cp path;more/Path;even/More/Path cucumber.api.cli.Main .

工作......只要黄瓜罐在类路径上。至少你需要在类路径上cucumber-core