Java Cucumber cli(cucumber.api.cli.Main)的--glue选项语法

时间:2015-08-11 15:35:48

标签: java eclipse cucumber cucumber-jvm cucumber-junit

我正在尝试从Windows命令行(Windows 10)运行Cucumber cli。到目前为止一切都好。我可以从正确的位置加载我的* .feature文件并告诉我需要实现哪些方法。我已经在类方法上创建了一个带有@Give,@ When,@Then符号的类,然后干净地编译了我的类。

.class文件位于Eclipse Project的\ bin目录的com \ company \ automation \子目录中,所有支持的jar都位于C:\ java中。我在.bat文件中使用以下语法尝试运行但Cucumber报告它无法找到我的方法并提示我写下这些“缺少的步骤”。

我正在使用的命令是:

java -classpath“C:\ java \ *”;“C:\ Users \ Mark \ workspace \ Company Automation \ bin \ *”cucumber.api.cli.Main --glue“C:\ Users \ Mark \ workspace \ Company Automation \ bin \ com \ company \ automation“”C:\ Users \ Mark \ workspace \ Company Automation \ Features“

我执行的“缺失步骤”如下:

package com.company.automation;

import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class CucumberImplementation {

    @Given("^I am a visitor$")
    public void i_am_a_visitor() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

    @When("^I visit \"([^\"]*)\"$")
    public void i_visit(String arg1) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

    @Then("^there must be a \"([^\"]*)\" element$")
    public void there_must_be_a_element(String arg1) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

    @Then("^the \"([^\"]*)\" element must contain a \"([^\"]*)\" element$")
    public void the_element_must_contain_a_element(String arg1, String arg2) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

    @Then("^the \"([^\"]*)\" element must contain a \"([^\"]*)\" link$")
    public void the_element_must_contain_a_link(String arg1, String arg2) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

    @Then("^there must be a \"([^\"]*)\" element after the \"([^\"]*)\" element$")
    public void there_must_be_a_element_after_the_element(String arg1, String arg2) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

}

我已经为--glue选项尝试了各种不同的路径形式,包括classpath:com.company.automation,classpath:com.company.automation.CucumberImplementation.class和类似但带有反斜杠和forwardslashes。似乎无论我使用什么语法为--glue选项的参数,Cucumber似乎完全忽略它,甚至没有在第一步抛出PendingException。它也不会抱怨--glue选项的论证是一条无效的道路,如果我只是在那里乱搞。

使用cucumber-core-1.2.4.jar作为基础。

1 个答案:

答案 0 :(得分:3)

有同样的问题。

这就是我解决它的方式(感谢上面的评论):

--glue com.test.app

其中“com.test.app”是我的步骤定义文件的包。