运行时无法识别Stepdef但是当我将鼠标悬停在.feature文件中的步骤时会识别它们为什么?

时间:2017-07-16 20:18:16

标签: java maven cucumber-jvm

我查看了以下类似的问题但不适用: Cucumber - implementing missing steps in java

cucumber not able to recognize the implemented methods

还查看了https://github.com/cucumber/cucumber/issues但没有点击

我正在运行带有黄瓜的Java 1.8,当我将鼠标悬停在.feature文件中的步骤时,我可以看到实现,但是当我运行测试时,我得到:

您可以使用以下代码段实现缺少的步骤:

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

@When("^I enter the non existent email$")
public void i_enter_the_non_existent_email() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^I enter the false password$")
public void i_enter_the_false_password() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^I click on it$")
public void i_click_on_it() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^I still on the page$")
public void i_still_on_the_page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

我想可能是我在项目配置中做了一些错误但是当我从https://github.com/cucumber/cucumber-java-skeleton

导入了黄瓜-java-skeleton时

当我使用我自己的实现填充skelton项目时,我在运行测试时遇到上述相同的错误,但当我将鼠标悬停在.feature文件中的步骤时,我仍然可以看到实现:

@Given("^I am on the Login Page$")
public void i_am_on_the_Login_Page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions

}

@When("^I enter the non existent email$")
public void i_enter_the_non_existent_email() throws Throwable {
    // Write code here that turns the phrase above into concrete actions

}

@When("^I enter the false password$")
public void i_enter_the_false_password() throws Throwable {
    // Write code here that turns the phrase above into concrete actions

}

@When("^I click on it$")
public void i_click_on_it() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
}

@Then("^I still on the page$")
public void i_still_on_the_bb() throws Throwable {
    // Write code here that turns the phrase above into concrete actions

} 

.feature文件:

 Feature: Login 


  Scenario: Testing with false credentials
    Given I am on the Login Page 
    When I enter the non existent email 
    And I enter the false password 
    And I click on it
    Then I still on the page

我正在使用Netbeans最新版本,其中包含与skelton项目相同的pom.xml文件。

我使用整洁的Gherkin将Gherkin翻译成Java代码

除了Tidy小黄瓜之外,还有其他方法可以让Gherkin特别是Java 8翻译成Java吗?也许这就是问题??

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我离开了我的电脑,所以我没有办法检查这个,但让你的Gherkin完全匹配你的方法名称。